#P9714. 「QFOI R1」摸摸
「QFOI R1」摸摸
Problem Description
Little R is a lovely girl, and she likes having her head patted.
However, before patting her head, you must answer a question she asks.
She has an array of length , where all elements are initially . There are also two arrays of length .
She can perform two kinds of operations:
- Add to the reversed element by element, obtaining a new .
- For example, becomes .
- Add to element by element, obtaining a new .
- For example, becomes .
Is it possible to turn into by performing the operations above some number of times?
You want to pat her head times, so there are test cases.
Input Format
The first line contains an integer , meaning the number of test cases.
For each test case:
- The first line contains an integer , meaning the array length.
- The second line contains integers, where the -th integer is .
- The third line contains integers, where the -th integer is .
Output Format
Output lines. Each line contains a string Yes or No, indicating whether it is possible to turn into for that test case.
The string is case-insensitive. If the answer is Yes, then yes, YES, yEs, etc. will all be accepted.
2
3
1 2 2
5 8 7
3
1 2 2
2 4 3
Yes
No
Hint
Sample Explanation
For the first test case:
- Initially: , , .
- Perform operation 2: , , .
- Perform operation 2: , , .
- Perform operation 1: , , .
- Perform operation 2: , , .
Now , which satisfies the requirement.
For the second test case, it can be proven that no valid solution exists.
Constraints
There are test points in total, with points for each test point.
Let denote the sum of over all test cases.
For all testdata, it is guaranteed that , , .
- For test points : it is guaranteed that .
- For test points : it is guaranteed that all are equal.
- For test points : it is guaranteed that .
- For test points : it is guaranteed that .
- For test points : no special constraints.
Hack Data
Hack data was added after the contest, numbered starting from .
The original test points are still worth points each, and the Hack data is worth points. However, you will be judged as Accepted only if you pass all data.
To distinguish the original test points from the Hack data, subtasks were added to this problem, but the scoring method of the subtasks is “sum”, which will not affect normal judging.
Translated by ChatGPT 5