Codeforces Round 812 (Div. 2)
F
Lost Array
Codeforces
2900
原题
← E→
翻译中…

My orzlers, we can optimize this problem from $O(S^3)$ to $O\left(T^\frac{5}{9}\right)$!— Spyofgame, founder of Orzlim religion

翻译中…

A long time ago, Spyofgame invented the famous array $a$ ($1$-indexed) of length $n$ that contains information about the world and life. After that, he decided to convert it into the matrix $b$ ($0$-indexed) of size $(n + 1) \times (n + 1)$ which contains information about the world, life and beyond.

翻译中…

Spyofgame converted $a$ into $b$ with the following rules.

翻译中…
  • $b_{i,0} = 0$ if $0 \leq i \leq n$;
  • $b_{0,i} = a_{i}$ if $1 \leq i \leq n$;
  • $b_{i,j} = b_{i,j-1} \oplus b_{i-1,j}$ if $1 \leq i, j \leq n$.
翻译中…

Here $\oplus$ denotes the bitwise XOR operation.

翻译中…

Today, archaeologists have discovered the famous matrix $b$. However, many elements of the matrix has been lost. They only know the values of $b_{i,n}$ for $1 \leq i \leq n$ (note that these are some elements of the last column, not the last row).

翻译中…

The archaeologists want to know what a possible array of $a$ is. Can you help them reconstruct any array that could be $a$?

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($1 \leq n \leq 5 \cdot 10^5$).

翻译中…

The second line contains $n$ integers $b_{1,n}, b_{2,n}, \ldots, b_{n,n}$ ($0 \leq b_{i,n} \lt 2^{30}$).

翻译中…

Output

翻译中…

If some array $a$ is consistent with the information, print a line containing $n$ integers $a_1, a_2, \ldots, a_n$. If there are multiple solutions, output any.

翻译中…

If such an array does not exist, output $-1$ instead.

翻译中…

Note

翻译中…

If we let $a = [1,2,3]$, then $b$ will be:

翻译中…

$\bf{0}$$\bf{1}$$\bf{2}$$\bf{3}$$\bf{0}$$1$$3$$0$$\bf{0}$$1$$2$$2$$\bf{0}$$1$$3$$1$

翻译中…

The values of $b_{1,n}, b_{2,n}, \ldots, b_{n,n}$ generated are $[0,2,1]$ which is consistent with what the archaeologists have discovered.

翻译中…

样例

Input #1
3
0 2 1
Output #1
1 2 3
InputCopy OutputCopy
Input #2
1
199633
Output #2
199633
InputCopy OutputCopy
Input #3
10
346484077 532933626 858787727 369947090 299437981 416813461 865836801 141384800 157794568 691345607
Output #3
725081944 922153789 481174947 427448285 516570428 509717938 855104873 280317429 281091129 1050390365
InputCopy OutputCopy
题目信息
题号
1713F
时间限制
1 s
内存限制
256 MB
标签
位运算
组合数学
构造
动态规划
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。