A sequence $S$ is defined as below:
$S_1 = \{ 1 \}$
$S_2 = S_1 + \{ 2 \} + S_1 = \{ 1,2,1 \}$
$S_3 = S_2 + \{ 3 \} + S_2 = \{ 1,2,1,3,1,2,1 \}$
...
$S_i = S_{i-1} + \{ i \} + S_{i-1}$
where $+$ means concatenation.
Now there is a number $x$, $x$ is initially $1$.
Given $N$ operation, which are of $2$ types:
Type $1$, $x := x+1$
Type $2$, $x := 2x$
Let $F(i)$ be the frequency of the the number $i$ in the first $x$ numbers of $S_{10^{10^9}}$ mod $10^9+7$.
Find $F(1)\oplus F(2)\oplus ... \oplus F(10^{10^9})$ after each operation, where $\oplus$ means XOR.
Input
On line 1, an integer $N$.
On line 2, $N$ integers, the $i$-th integer is $t_{i}$, the type of the $i$-th operation.
Output
Output $N$ numbers, the $i$-th number should be the desired answer after the $i$-th operation.
Subtasks
For all cases,
$1 \le N \le 10^6$
Subtask $1$ ($10$ pts): There are only type $1$ operations.
Subtask $2$ ($17$ pts): There are only type $2$ operations.
Subtask $3$ ($14$ pts): All type $1$ operations are after type $2$ operations.
Subtask $4$ ($24$ pts): There are no consecutive type $1$ operations.
Subtask $5$ ($16$ pts): There are at most $10$ type $1$ operations.
Subtask $6$ ($19$ pts): No Additional Constraints.
Sample Test Cases
| Input | Output | |
|---|---|---|
| 3 2 1 2 |
0 3 0 | |
$S_{10^{10^9}}=\{ 1,2,1,3,1,2,1,4,1,... \}$ $x=1$ initially. After the first operation, $x=2$ $F(1)=1$ $F(2)=1$ All other values of $F$ is $0$ The answer is $1\oplus 1 =0$ After the second operation, $x=3$ $F(1)=2$ $F(2)=1$ All other values of $F$ is $0$ The answer is $2\oplus 1 =3$ After the third operation, $x=6$ $F(1)=3$ $F(2)=2$ $F(3)=1$ All other values of $F$ is $0$ The answer is $3\oplus 2 \oplus 1 =0$ |
||
| 5 1 1 2 2 1 |
0 3 0 6 7 | |
Scoring: Per Subtask
Authored by s23f32
Appeared in WYOI Round 0 [April Edition]