Logo
(追記) (追記ここまで)

20236번 - Easy Compare-and-Set 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB93312029.851%

문제

Let us define "Compare-and-Set" operation for a global variable $v$. The operation checks if the variable is equal to $a$. If that's true, the variable value changes to $b$ and the operation succeeds. Otherwise, the variable doesn't change and the operation fails. Let us denote the operation as $\operatorname{CAS}(a,b)$.

Imagine that you are given a list of such operations $\operatorname{CAS}(a_1,b_1), \dots, \operatorname{CAS}(a_n,b_n)$. Also, you are given an initial value for the variable, $c,ドル and a list of wishes $w_1, \dots w_n,ドル where $w_i$ tells whether the operation $\operatorname{CAS}(a_i,b_i)$ should be successful. Your task is to determine the order of operations execution so that all the wishes are satisfied.

입력

The first line contains two integers $n$ and $c$ (1ドル \le n \le 10^5$; 1ドル \le c \le 10^9$) --- the number of operations and the initial value of the variable.

Each of the next $n$ lines contains three integers $a_i, b_i, w_i$ (1ドル \le a_i, b_i \le 10^9$; 0ドル \le w_i \le 1$), denoting $\operatorname{CAS}(a_i, b_i)$ operation that you wish to be successful if $w_i = 1$ and unsuccessful if $w_i = 0$. The operations are numbered from 1ドル$ to $n$ in order of input.

출력

If no correct order of operations exists, output a single word "No".

Otherwise, output a word "Yes" followed by $n$ distinct integers $p_1, p_2, \ldots p_n$ (1ドル \le p_i \le n$), meaning that operation $p_1$ should be executed first, then operation $p_2,ドル and so on. If there are several possible orders, output any of them.

제한

예제 입력 1

4 1
1 2 0
1 2 1
2 3 1
3 4 0

예제 출력 1

Yes
4 2 1 3

예제 입력 2

3 1
1 2 1
1 2 1
1 2 0

예제 출력 2

No

힌트

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2020-2021 North-Western Russia Regional Contest E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /