3016.Interesting Array

Time Limit: 1s Memory Limit: 256MB

We'll call an array of n non-negative integers a[1],a[2],...,a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 \le li \le ri \le n) meaning that value 3016_1.png should be equal to qi.

Your task is to find any interesting array of n elements or state that such array doesn't exist.

Expression x&y means the bitwise AND of numbers x and y. In programming languages C++, Java and Python this operation is represented as "&", in Pascal - as "and".

Input Format(From the terminal/stdin)

The first line contains two integers n, m (1 \le n \le 105, 1 \le m \le 105)- the number of elements in the array and the number of limits.

Each of the next m lines contains three integers li, ri, qi (1 \le li \le ri \le n, 0 \le qi \lt 230) describing the i-th limit.

Output Format(To the terminal/stdout)

If the interesting array exists, in the first line print "YES" (without the quotes) and in the second line print n integers a[1],a[2],...,a[n] (0 \le a[i] \lt 230)decribing the interesting array. If there are multiple answers, print any of them.

If the interesting array doesn't exist, print "NO" (without the quotes) in the single line.

Sample Input 1

Copy
3 1
1 3 3
 · \n
 · · \n

Sample Output 1

Copy
YES
3 3 3
   \n
 · · \n

Sample Input 2

Copy
3 2
1 3 3
1 3 2
 · \n
 · · \n
 · · \n

Sample Output 2

Copy
NO
  \n

Submit

请先 登录

© 2025 FAQs