33OJ
登录 注册

E. 小于与小于等于 / lt and le

    传统题 2000ms 256MiB

小于与小于等于 / lt and le

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Statement

Determine whether there exists an integer sequence AA of length NN consisting of integers between 11 and NN, inclusive, that satisfies all of the following QQ conditions, and if it exists, find one.

The ii-th condition (1≤i≤Q)(1 \le i \le Q) is given by a triple of integers (ti,ui,vi)(t_i, u_i, v_i), and is defined as follows.

  • If ti=0t_i = 0: Aui≤AviA_{u_i} \le A_{v_i}
  • If ti=1t_i = 1: Aui<AviA_{u_i} \lt A_{v_i}

If there are multiple sequences satisfying all conditions, you may output any of them.

Constraints

  • 1≤N≤2×1051 \le N \le 2 \times 10^5
  • 1≤Q≤2×1051 \le Q \le 2 \times 10^5
  • ti∈{0,1} (1≤i≤Q)t_i \in \lbrace 0, 1 \rbrace\ (1 \le i \le Q)
  • 1≤ui≤N (1≤i≤Q)1 \le u_i \le N\ (1 \le i \le Q)
  • 1≤vi≤N (1≤i≤Q)1 \le v_i \le N\ (1 \le i \le Q)
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

  • NN QQ
  • t1t_1 u1u_1 v1v_1
  • t2t_2 u2u_2 v2v_2
  • ⋮\vdots
  • tQt_Q uQu_Q vQv_Q

Output

On the first line, output Yes if an integer sequence satisfying the conditions exists, and No otherwise. If you output Yes on the first line, choose one integer sequence satisfying the conditions and output its elements, separated by spaces, on the second line. If there are multiple sequences satisfying all the conditions, you may choose any of them.

7 8
0 1 4
0 2 6
0 3 2
1 3 5
0 4 1
0 4 3
1 5 7
0 6 7
Yes
1 4 2 1 3 5 6

Let A=(1,4,2,1,3,5,6)A=(1,4,2,1,3,5,6); this is an integer sequence of length 77 consisting of integers between 11 and 77, inclusive. Here, for example, the first condition A1≤A4A_1 \le A_4 holds since 1≤11 \le 1. The other seven conditions also hold, so the output corresponding to A=(1,4,2,1,3,5,6)A=(1,4,2,1,3,5,6) is considered correct.

Additionally, A=(1,1,1,1,2,2,3)A=(1,1,1,1,2,2,3), A=(3,5,4,3,6,7,7)A=(3,5,4,3,6,7,7), and others also satisfy the conditions, so outputting these is also considered correct.

1 1
1 1 1
No

There is no integer sequence AA such that A1<A1A_1 \lt A_1 holds.

15 20
0 9 8
1 6 1
0 6 8
0 11 1
0 4 2
1 11 12
0 4 14
1 10 1
0 12 12
1 7 12
1 13 1
1 5 9
1 10 14
1 14 1
1 8 12
0 10 12
1 4 15
1 3 9
0 5 14
0 10 2
Yes
15 14 10 7 6 5 4 12 11 3 2 13 1 9 8

ABC478 赛后模拟赛 ✅️

未参加
状态
已结束
规则
IOI
题目
7
开始于
2026-10-10 21:40
结束于
2026-10-24 21:40
持续时间
336 小时
主持人
参赛人数
59