GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Saturday, 20 August 2022

[Solution] 2+ doors Codeforces Solution|Solution Codeforces



D. 2+ doors
time limit per test
1.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.
Input

In the first line you are given with two integers n and q (1≤n≤105, 0≤q≤2⋅105).

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

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.

Output

On a single line print n integers a1,a2,…,an (0≤ai<230) — array a.

No comments:

Post a Comment