A15347 | 2+ doors
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The Narrator has an integer array $a$ of length $n$ , but he will only tell you the size $n$ and $q$ statements, each of them being three integers $i, j, x$ , which means that $a_i \mid a_j = x$ , where $|$ denotes the [bitwise OR operation](https://en.wikipedia.org/wiki/Bitwise_operation#OR).
Find the lexicographically smallest array $a$ that satisfies all the statements.
An array $a$ is lexicographically smaller than an array $b$ of the same length if and only if the following holds:
- in the first position where $a$ and $b$ differ, the array $a$ has a smaller element than the corresponding element in $b$ .
Find the lexicographically smallest array $a$ that satisfies all the statements.
An array $a$ is lexicographically smaller than an array $b$ of the same length if and only if the following holds:
- in the first position where $a$ and $b$ differ, the array $a$ has a smaller element than the corresponding element in $b$ .
输入格式
In the first line you are given with two integers $n$ and $q$ ( $1 \le n \le 10^5$ , $0 \le q \le 2 \cdot 10^5$ ).
In the next $q$ lines you are given with three integers $i$ , $j$ , and $x$ ( $1 \le i, j \le n$ , $0 \le x < 2^{30}$ ) — the statements.
It is guaranteed that all $q$ statements hold for at least one array.
In the next $q$ lines you are given with three integers $i$ , $j$ , and $x$ ( $1 \le i, j \le n$ , $0 \le x < 2^{30}$ ) — the statements.
It is guaranteed that all $q$ statements hold for at least one array.
输出格式
On a single line print $n$ integers $a_1, a_2, \ldots, a_n$ ( $0 \le a_i < 2^{30}$ ) — array $a$ .
输入输出样例
输入 #1
4 3 1 2 3 1 3 2 4 1 2
输出 #1
0 3 2 2
输入 #2
1 0
输出 #2
0
输入 #3
2 1 1 1 1073741823
输出 #3
1073741823 0
In the first sample, these are all the arrays satisfying the statements:
- $[0, 3, 2, 2]$ ,
- $[2, 1, 0, 0]$ ,
- $[2, 1, 0, 2]$ ,
- $[2, 1, 2, 0]$ ,
- $[2, 1, 2, 2]$ ,
- $[2, 3, 0, 0]$ ,
- $[2, 3, 0, 2]$ ,
- $[2, 3, 2, 0]$ ,
- $[2, 3, 2, 2]$ .
- $[0, 3, 2, 2]$ ,
- $[2, 1, 0, 0]$ ,
- $[2, 1, 0, 2]$ ,
- $[2, 1, 2, 0]$ ,
- $[2, 1, 2, 2]$ ,
- $[2, 3, 0, 0]$ ,
- $[2, 3, 0, 2]$ ,
- $[2, 3, 2, 0]$ ,
- $[2, 3, 2, 2]$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted