A8860 | Restoring Table
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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}$ .
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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted