#P8053. [COCI 2015/2016 #4] DEATHSTAR
[COCI 2015/2016 #4] DEATHSTAR
Problem Description
After overcoming many difficulties, you have infiltrated the Death Star. To destroy it, you need an array of length 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 matrix in advance. In this matrix, the element in row and column satisfies , where means the bitwise AND operation. Just when you thought you could directly obtain the array 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 .
Now, based on the other undamaged elements, find any array that satisfies the requirements.
Input Format
The first line contains an integer , the order of the matrix .
Then follow lines, each containing integers describing the matrix .
Output Format
Output one line with integers, representing an array that satisfies the conditions. Each element of the array must be a non-negative integer not exceeding .
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 , but please note that this is not the only possible answer.
[Constraints]
For all testdata, , .
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 points.
Translated and organized by Eason_AC.
Translated by ChatGPT 5