405564: GYM101992 L Reflection
Memory Limit:1024 MB
Time Limit:15 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
L. Reflectiontime limit per test15 secondsmemory limit per test1024 megabytesinputreflection.inoutputstandard output
You are given a line with equation x = y. you need to perform the following operation Q times.
- For the ith operation, you are given an integer x and you are requested to find and print the corresponding value of its y coordinate on the current graph (assume that it equals to yi ).
- After finding yi, you should reflect the right part of the current graph (with x coordinates greater than or equal to xi) on the horizontal line y = yi .
Note that each operation depends on all operations before it.
InputThe first line of the input is the number of test cases T, each test case starts with a line containing a single integer Q the number of operations, where 1 ≤ Q ≤ 105.
Each of the following Q lines represents a query with a single integer x, where 0 ≤ xi ≤ 105.
OutputFor each test case output Q lines. Each of them contains the corresponding y value.
ExampleInput1Output
5
1
2
1
3
4
1Note
0
1
1
2
Here are some figures that illustrate the first 2 operations: