#P5754. [JSOI2010] 排名
[JSOI2010] 排名
Description
Given an array of length , where means that the -th student’s score is lower than the -th student’s score (equivalently, the -th student is ranked after the -th student). Of course, may equal , which means there is no information about the -th student.
You need to obtain an array of length , representing the class ranking. Among all rankings that satisfy all constraints given by , this ranking should be the lexicographically smallest one.
At the same time, you also need to obtain an array , representing the class ranking. Among all rankings that satisfy all constraints given by , this ranking should be the lexicographically largest one.
Input Format
The first line contains a positive integer , the number of students in the class.
The second line contains non-negative integers separated by spaces. The -th number denotes .
Output Format
Output two lines. Each line contains positive integers separated by spaces. The first line is Little H’s mental ranking, and the second line is Little X’s mental ranking.
4
3 0 2 2
3 1 2 4
4 1 3 2
Hint
Sample Explanation
There are rankings that satisfy the ordering constraints:
4 1 3 2
4 1 2 3
3 1 2 4
Among them, 3 1 2 4 is lexicographically smallest, and 4 1 3 2 is lexicographically largest.
Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, . Among them, the -th testdata group guarantees .
Translated by ChatGPT 5
京公网安备 11011102002149号