CF1715D.2+ doors
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 ai∣aj=x , where ∣ denotes the bitwise OR operation.
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≤n≤105 , 0≤q≤2⋅105 ).
In the next q lines you are given with three integers i , j , and x ( 1≤i,j≤n , 0≤x<230 ) — the statements.
It is guaranteed that all q statements hold for at least one array.
输出格式
On a single line print n integers a1,a2,…,an ( 0≤ai<230 ) — 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] .