Scoreboard Screenshots
InterviewTime limit2sMemory limit256 MB
Given N scoreboard screenshots of K teams, find an order in which every team's score never decreases, or report NO if none exists.
- Level
Easy3 of 10
- Topics
- Sorting, Array, Implementation
- Solved
- No attempts yet
Problem
The MITIT 2025 Winter Contest has ended with teams participating, and Busy Beaver has to write a report on the contest.
For the report, Busy Beaver took screenshots of the scoreboard during the contest. Each screenshot shows the scores of all teams at the moment it was taken.
Unfortunately, Busy Beaver forgot the order in which he took the screenshots. If there were no regrades during the contest, each team's score would be nondecreasing over time. Under this assumption, Busy Beaver wants to recover the order of the screenshots.
Determine whether a valid ordering exists in which no team's score decreases over time. If one exists, print any such ordering.
Input
The first line contains two integers and (; ), the number of screenshots and the number of teams.
The -th of the next lines contains integers (), where is the score of the -th team in the -th screenshot.
Output
If a valid ordering exists, print YES on the first line. On the second line, print integers , where is the index of the screenshot placed at position in the ordering. If there are multiple solutions, you can print any of them.
If no valid ordering exists, print NO.