CF796F.Sequence Recovery

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Zane once had a good sequence aa consisting of nn integers a1,a2,...,ana_{1},a_{2},...,a_{n} — but he has lost it.

A sequence is said to be good if and only if all of its integers are non-negative and do not exceed 10910^{9} in value.

However, Zane remembers having played around with his sequence by applying mm operations to it.

There are two types of operations:

1. Find the maximum value of integers with indices ii such that l<=i<=rl<=i<=r , given ll and rr .

2. Assign dd as the value of the integer with index kk , given kk and dd .

After he finished playing, he restored his sequence to the state it was before any operations were applied. That is, sequence aa was no longer affected by the applied type 2 operations. Then, he lost his sequence at some time between now and then.

Fortunately, Zane remembers all the operations and the order he applied them to his sequence, along with the distinct results of all type 1 operations. Moreover, among all good sequences that would produce the same results when the same operations are applied in the same order, he knows that his sequence aa has the greatest cuteness.

We define cuteness of a sequence as the bitwise OR result of all integers in such sequence. For example, the cuteness of Zane's sequence aa is a1a_{1} OR a2a_{2} OR ... OR ana_{n} .

Zane understands that it might not be possible to recover exactly the lost sequence given his information, so he would be happy to get any good sequence bb consisting of nn integers b1,b2,...,bnb_{1},b_{2},...,b_{n} that:

1. would give the same results when the same operations are applied in the same order, and

2. has the same cuteness as that of Zane's original sequence aa .

If there is such a sequence, find it. Otherwise, it means that Zane must have remembered something incorrectly, which is possible.

输入格式

The first line contains two integers nn and mm ( 1<=n,m<=31051<=n,m<=3·10^{5} ) — the number of integers in Zane's original sequence and the number of operations that have been applied to the sequence, respectively.

The ii -th of the following mm lines starts with one integer tit_{i} () — the type of the ii -th operation.

If the operation is type 1 ( ti=1t_{i}=1 ), then three integers lil_{i} , rir_{i} , and xix_{i} follow ( 1<=li<=ri<=n1<=l_{i}<=r_{i}<=n , 0<=xi<=1090<=x_{i}<=10^{9} ) — the leftmost index to be considered, the rightmost index to be considered, and the maximum value of all integers with indices between lil_{i} and rir_{i} , inclusive, respectively.

If the operation is type 2 ( ti=2t_{i}=2 ), then two integers kik_{i} and did_{i} follow ( 1<=ki<=n1<=k_{i}<=n , 0<=di<=1090<=d_{i}<=10^{9} ) — meaning that the integer with index kik_{i} should become did_{i} after this operation.

It is guaranteed that xixjx_{i}≠x_{j} for all pairs (i,j)(i,j) where 1<=i<j<=m and ti=tj=1t_{i}=t_{j}=1 .

The operations are given in the same order they were applied. That is, the operation that is given first was applied first, the operation that is given second was applied second, and so on.

输出格式

If there does not exist a valid good sequence, print "NO" (without quotation marks) in the first line.

Otherwise, print "YES" (without quotation marks) in the first line, and print nn space-separated integers b1,b2,...,bnb_{1},b_{2},...,b_{n} ( 0<=bi<=1090<=b_{i}<=10^{9} ) in the second line.

If there are multiple answers, print any of them.

输入输出样例

  • 输入#1

    5 4
    1 1 5 19
    1 2 5 1
    2 5 100
    1 1 5 100
    

    输出#1

    YES
    19 0 0 0 1
    
  • 输入#2

    5 2
    1 1 5 0
    1 1 5 100
    

    输出#2

    NO

说明/提示

In the first sample, it is easy to verify that this good sequence is valid. In particular, its cuteness is 1919 OR 00 OR 00 OR 00 OR 11 == 1919 .

In the second sample, the two operations clearly contradict, so there is no such good sequence.

首页