CF1903B.StORage room
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In Cyprus, the weather is pretty hot. Thus, Theofanis saw this as an opportunity to create an ice cream company.
He keeps the ice cream safe from other ice cream producers by locking it inside big storage rooms. However, he forgot the password. Luckily, the lock has a special feature for forgetful people!
It gives you a table M with n rows and n columns of non-negative integers, and to open the lock, you need to find an array a of n elements such that:
- 0≤ai<230 , and
- Mi,j=ai∣aj for all i=j , where ∣ denotes the bitwise OR operation.
The lock has a bug, and sometimes it gives tables without any solutions. In that case, the ice cream will remain frozen for the rest of eternity.
Can you find an array to open the lock?
输入格式
The first line contains a single integer t ( 1≤t≤103 ) — the number of test cases.
The first line of each test case contains a single integer n ( 1≤n≤103 ) — the size of the hidden array.
The next n lines describe the rows of M , line i contains the table values Mi,1,Mi,2,…,Mi,n ( 0≤Mi,j<230 ).
It is guaranteed that Mi,i=0 and Mi,j=Mj,i for all 1≤i,j≤n .
It is also guaranteed that the sum of n over all test cases does not exceed 103 .
输出格式
For each test case, if there is a solution print YES and an array that satisfies the property, otherwise print NO.
If there are multiple solutions, print any of them.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
输入输出样例
输入#1
4 1 0 4 0 3 3 5 3 0 3 7 3 3 0 7 5 7 7 0 5 0 7 7 5 5 7 0 3 2 6 7 3 0 3 7 5 2 3 0 4 5 6 7 4 0 3 0 0 1 0 0 0 1 0 0
输出#1
YES 7 YES 1 3 2 5 YES 5 2 3 0 4 NO