CF482B.Interesting Array
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 l__i, r__i, q__i (1 ≤ l__i ≤ r__i ≤ n) meaning that value
should be equal to q__i.
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".
我们将一个由 n 个非负整数组成的数组 a[1], a[2], …, a[n] 称为“有趣的”,当且仅当它满足 m 个约束条件。第 i 个约束由三个整数 li, ri, qi(其中 1≤li≤ri≤n)组成,表示值

应等于 qi。
你的任务是构造出任意一个满足条件的、长度为 n 的“有趣”数组;若不存在这样的数组,则说明其不存在。
表达式 x & y 表示数字 x 与 y 的按位与运算。在编程语言 C++、Java 和 Python 中,该运算符写作 &,而在 Pascal 中则写作 and。
输入格式
The first line contains two integers n, m (1 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of elements in the array and the number of limits.
Each of the next m lines contains three integers l__i, r__i, q__i (1 ≤ l__i ≤ r__i ≤ n, 0 ≤ q__i < 230) describing the i-th limit.
第一行包含两个整数 n、m(1 ≤ n ≤ 105,1 ≤ m ≤ 105)—— 分别表示数组的元素个数和限制条件的个数。
接下来的 m 行中,每行包含三个整数 li、ri、qi(1 ≤ li ≤ ri ≤ n,0 ≤ qi < 230),描述第 i 个限制条件。
输出格式
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 ≤ a[i] < 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.
如果存在满足条件的有趣数组,则在第一行输出 "YES"(不带引号),在第二行输出 n 个整数 a[1], a[2], ..., a[n](其中 0 ≤ a[i] < 230),用以描述该有趣数组。若存在多个解,输出任意一个即可。
如果不存在满足条件的有趣数组,则在单独一行中输出 "NO"(不带引号)。
输入输出样例
输入#1
3 1 1 3 3
输出#1
YES 3 3 3
输入#2
3 2 1 3 3 1 3 2
输出#2
NO
输入解题思路,AI测评打分。不知道怎么写?