Elimination Race
시간 제한1초메모리 제한1024 MB
각 참가자마다 n-1개의 트랙 순서를 잘 정해 모든 경기에서 꼴찌를 면하고 우승할 수 있는지 판정하고, 가능하면 그 순서를 출력한다.
문제
You are participating in an elimination race championship. The championship is held for participants with assigned numbers from to and consists of races on different tracks. After each race, the participant who comes the last is eliminated. After all races, the only remaining participant is crowned as the champion.
As an experienced participant, you know how fast each car can go on each track, and therefore, you can predict the results of each race. However, the order of tracks is not yet determined. Your task is to find out for every participant whether there exists a permutation of the tracks that can grant him a victory.
입력
The first line contains the only integer (): the number of participants.
Each of the following lines describes a track and contains a permutation of numbers from to : the order in which the participants get to the finish on that track, from fastest to slowest.
출력
You should print answers. The -th answer should have the following format.
If winning the championship is possible for -th participant, you should print "Yes" (without quotes, case insensitive) on the first line. On the second line, print a permutation of integers from to : the order of tracks which grants victory to the -th participant. Tracks are numbered in the order they are given in the input.
Otherwise, you should output "No" on a single line.
If multiple answers exist, print any one of them.