#P8053. [COCI 2015/2016 #4] DEATHSTAR

    ID: 9148 远端评测题 1000ms 64MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>2015Special JudgeO2优化位运算COCI(克罗地亚)

[COCI 2015/2016 #4] DEATHSTAR

Problem Description

After overcoming many difficulties, you have infiltrated the Death Star. To destroy it, you need an array aa of length nn to start the Death Star’s self-destruction command. Although you do not know what this array is, your old friend Darth Vader gave you an n×nn \times n matrix bb in advance. In this matrix, the element in row ii and column jj satisfies bi,j=ai and ajb_{i,j}=a_i\operatorname{~and~} a_j, where and\operatorname{and} means the bitwise AND operation. Just when you thought you could directly obtain the array aa from this matrix, you found that all elements on the main diagonal were destroyed by a lightsaber. You cannot read their values, so they are temporarily replaced with 00.

Now, based on the other undamaged elements, find any array aa that satisfies the requirements.

Input Format

The first line contains an integer nn, the order of the matrix bb.
Then follow nn lines, each containing nn integers describing the matrix bb.

Output Format

Output one line with nn integers, representing an array aa that satisfies the conditions. Each element of the array must be a non-negative integer not exceeding 10910^9.

The testdata guarantees that a solution exists, but it is not guaranteed to be unique.

3
0 1 1
1 0 1
1 1 0
1 1 1
5
0 0 1 1 1
0 0 2 0 2
1 2 0 1 3
1 0 1 0 1
1 2 3 1 0
1 2 3 1 11

Hint

[Sample 1 Explanation]

It is easy to see that one valid array is a=[1,1,1]a=[1,1,1], but please note that this is not the only possible answer.

[Constraints]

For all testdata, 1n10001\leqslant n\leqslant 1000, 0bi,j1090\leqslant b_{i,j}\leqslant 10^9.

This problem uses Special Judge. If you have testdata that can hack the checker written by the problem setter, or if you have suggestions to improve the checker, feel free to post them in the discussion area below this problem.

[Source]

This problem is from COCI 2015-2016 CONTEST 4 T3 DEATHSTAR, using the original test configuration, with a full score of 100100 points.

Translated and organized by Eason_AC.

Translated by ChatGPT 5