Easy Compare-and-Set
시간 제한2초메모리 제한512 MB
초기값과 함께 성공 또는 실패가 요구되는 CAS(a,b) 연산들이 주어질 때, 모든 요구를 만족하는 실행 순서를 찾거나 불가능함을 판정한다.
문제
Let us define "Compare-and-Set" operation for a global variable . The operation checks if the variable is equal to . If that's true, the variable value changes to and the operation succeeds. Otherwise, the variable doesn't change and the operation fails. Let us denote the operation as .
Imagine that you are given a list of such operations . Also, you are given an initial value for the variable, , and a list of wishes , where tells whether the operation 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 and (; ) --- the number of operations and the initial value of the variable.
Each of the next lines contains three integers (; ), denoting operation that you wish to be successful if and unsuccessful if . The operations are numbered from to in order of input.
출력
If no correct order of operations exists, output a single word "No".
Otherwise, output a word "Yes" followed by distinct integers (), meaning that operation should be executed first, then operation , and so on. If there are several possible orders, output any of them.