#P1960. 郁闷的记者
郁闷的记者
Description
You are a reporter for a sports newspaper, and you have received a challenging task: there are football teams participating in a tournament. You are given some match results and need to output the ranking of all teams from to .
The following information applies:
- There are no draws.
- Different teams cannot share the same rank.
- For all , the team in position must be able to defeat the team in position .
Given partial match results, output one valid ranking, and determine whether there exists another ranking that also satisfies the given results.
Input Format
The first line contains , the number of teams, numbered from to .
The second line contains , the number of given matches.
Each of the next lines contains two integers , , meaning team can defeat team .
Output Format
Output lines. The first lines describe the ranking of the teams: the -th line contains the team ranked -th. The -th line contains one integer; output if there is no other ranking that satisfies the given results, or if there is at least one other valid ranking.
3
2
2 1
2 3
2
1
3
1
Hint
Constraints
- of the testdata satisfies: , .
- of the testdata satisfies: , .
- of the testdata satisfies: , .
This problem uses Special Judge.
- If the last line is incorrect, the message will be
Your decide is wrong!. - If multiple rankings are possible and your ranking is wrong, the message will be
Wrong ranks!. - If the ranking is unique and your answer is wrong, the message will be
In line X,Your ans is wrong:expected = X,found = Y.
Translated by ChatGPT 5
京公网安备 11011102002149号