Scoreboard Screenshots

시간 제한2초메모리 제한256 MB

요약
각 스크린샷이 K개 팀의 점수를 담고 있을 때, 모든 팀의 점수가 감소하지 않도록 스크린샷 N개의 순서를 정한다.
난이도

보통10점 중 6점

유형
위상 정렬, 그래프, 정렬
정답자
아직 제출이 없습니다

문제

The MITIT 2025 Winter Contest has successfully ended with the participation of KK teams, and Busy Beaver has to write a report for the contest.

For the report, Busy Beaver took NN screenshots of the scoreboard during the contest. Each screenshot contains the scores of all KK teams when the screenshot was taken.

Unfortunately, Busy Beaver forgot in which order he took the screenshots! He assumes that if there were no regrades during the contest, each team’s score will be nondecreasing over time. Under this assumption, Busy Beaver wants to recover the order of the screenshots.

Determine if there is a valid ordering such that no team’s score decreases over time, and if it exists, print any such order.

입력

The first line contains two integers NN and KK (2≤N≤4002\leq N\leq 400; 1≤K≤4001\leq K\leq 400) — the number of screenshots and teams.

The ii-th of the next NN lines contains KK integers a_i,1,a_i,2,⋯ ,a_i,ka\_{i,1},a\_{i,2},\cdots ,a\_{i,k} (0≤a_i,j≤9000\leq a\_{i,j}\leq 900), where a_i,ja\_{i,j} is the score of the jj-th team in the ii-th screenshot.

출력

If a valid ordering exists, print “YES” (without quotes) on the first line. On the second line, print NN integers b_1,⋯ ,b_Nb\_1,\cdots ,b\_N, where b_ib\_i is the index of the ii-th screenshot in the valid ordering. If there are multiple solutions, you can print any of them.

If there is no valid ordering, print “NO” (without quotes).

예제2

  1. 예제 1

    입력
    3 2
    1 1
    0 0
    0 1
    
    예상 출력
    YES
    2 3 1
    
  2. 예제 2

    입력
    3 3
    0 0 1
    1 0 0
    0 1 0
    
    예상 출력
    NO