301311: CF245D. Restoring Table

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Restoring Table

题意翻译

### 题目描述 最近,Polycarpus在学校学习了非负整数的“按位与”运算。现在,他想去学校的信息教练那显摆显摆。 Polycarpus提前在黑板上写了一串非负整数$a_1, a_2, ..., a_n$。他还写了一个一个$n \times n$的矩阵$b$。其中第$i$行$j$列的元素被记为$b_{i,j}$。其规则如下所示: - 若$i=j$,则$b_{i,j}= a_i \ \&\ a_j$; - 若$i\neq j$,则$b_{i,j}=-1$。 现在,他十分高兴,于是决定把$a$序列给擦了。不幸的是,老师想再看看$a$序列,好给Polycarpus找茬。现在Polycarpus非常焦虑,因为如果他求不出原来的序列,那他就会非常的难堪。 现在,给你$b$矩阵,请你求出$a$序列。Polycarpus并不是非常喜欢大数,所以你给出的$a$序列不能超过$10^9$。 ### 输入格式 第一行包含一个整数$n(1\leq n \leq 100)$,代表矩阵$b$的边长。 接下来有$n$行,每行$n$个数,代表矩阵$b$。第$i$行的第$j$个数代表$b_{i,j}$。保证$1\leq i,j \leq n; i\neq j; b_{i,i}=-1; b_{i,j}\leq 10^9; b_{i,j}=b_{j,i}$。 ### 输出格式 输出一行,$n$个整数,代表$a$序列。 若有多组解,输出任意一组即可。 Translated by [\_FILARET_](https://www.luogu.com.cn/user/84121)

题目描述

Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation. For that Polycarpus came to school a little earlier and wrote on the board a sequence of non-negative integers $ a_{1},a_{2},...,a_{n} $ . He also wrote a square matrix $ b $ of size $ n×n $ . The element of matrix $ b $ that sits in the $ i $ -th row in the $ j $ -th column (we'll denote it as $ b_{ij} $ ) equals: - the "bitwise AND" of numbers $ a_{i} $ and $ a_{j} $ (that is, $ b_{ij}=a_{i} & a_{j} $ ), if $ i≠j $ ; - -1, if $ i=j $ . Having written out matrix $ b $ , Polycarpus got very happy and wiped $ a $ off the blackboard. But the thing is, the teacher will want this sequence to check whether Polycarpus' calculations were correct. Polycarus urgently needs to restore the removed sequence of integers, or else he won't prove that he can count correctly. Help Polycarpus, given matrix $ b $ , restore the sequence of numbers $ a_{1},a_{2},...,a_{n} $ , that he has removed from the board. Polycarpus doesn't like large numbers, so any number in the restored sequence mustn't exceed $ 10^{9} $ .

输入输出格式

输入格式


The first line contains a single integer $ n $ $ (1<=n<=100) $ — the size of square matrix $ b $ . Next $ n $ lines contain matrix $ b $ . The $ i $ -th of these lines contains $ n $ space-separated integers: the $ j $ -th number represents the element of matrix $ b_{ij} $ . It is guaranteed, that for all $ i $ $ (1<=i<=n) $ the following condition fulfills: $ b_{ii} $ = -1. It is guaranteed that for all $ i,j $ $ (1<=i,j<=n; i≠j) $ the following condition fulfills: $ 0<=b_{ij}<=10^{9} $ , $ b_{ij}=b_{ji} $ .

输出格式


Print $ n $ non-negative integers $ a_{1},a_{2},...,a_{n} $ $ (0<=a_{i}<=10^{9}) $ — the sequence that Polycarpus wiped off the board. Separate the numbers by whitespaces. It is guaranteed that there is sequence $ a $ that satisfies the problem conditions. If there are multiple such sequences, you are allowed to print any of them.

输入输出样例

输入样例 #1

1
-1

输出样例 #1

0 

输入样例 #2

3
-1 18 0
18 -1 0
0 0 -1

输出样例 #2

18 18 0 

输入样例 #3

4
-1 128 128 128
128 -1 148 160
128 148 -1 128
128 160 128 -1

输出样例 #3

128 180 148 160 

说明

If you do not know what is the "bitwise AND" operation please read: http://en.wikipedia.org/wiki/Bitwise\_operation.

Input

题意翻译

### 题目描述 最近,Polycarpus在学校学习了非负整数的“按位与”运算。现在,他想去学校的信息教练那显摆显摆。 Polycarpus提前在黑板上写了一串非负整数$a_1, a_2, ..., a_n$。他还写了一个一个$n \times n$的矩阵$b$。其中第$i$行$j$列的元素被记为$b_{i,j}$。其规则如下所示: - 若 $i \ne j$,则$b_{i,j}= a_i \ \&\ a_j$; - 若 $i = j$,则$b_{i,j}=-1$。 现在,他十分高兴,于是决定把$a$序列给擦了。不幸的是,老师想再看看$a$序列,好给Polycarpus找茬。现在Polycarpus非常焦虑,因为如果他求不出原来的序列,那他就会非常的难堪。 现在,给你$b$矩阵,请你求出$a$序列。Polycarpus并不是非常喜欢大数,所以你给出的$a$序列不能超过$10^9$。 ### 输入格式 第一行包含一个整数$n(1\leq n \leq 100)$,代表矩阵$b$的边长。 接下来有$n$行,每行$n$个数,代表矩阵$b$。第$i$行的第$j$个数代表$b_{i,j}$。保证$1\leq i,j \leq n; i\neq j; b_{i,i}=-1; b_{i,j}\leq 10^9; b_{i,j}=b_{j,i}$。 ### 输出格式 输出一行,$n$个整数,代表$a$序列。 若有多组解,输出任意一组即可。 Translated by [\_FILARET_](https://www.luogu.com.cn/user/84121)

加入题单

上一题 下一题 算法标签: