European Girls' Olympiad in Informatics: 2023 Day 2 Problem 1
Every four years, the students of Lund come together to organize the Lund Carnival. For a few days, a park fills with tents where all kinds of festive activities take place. The person in charge of making this happen is the carnival general.
In total, there have been
The next Lund Carnival will be in 2026. In the meantime, all past carnival generals have gathered to take a group photo. However, it would be awkward if generals
For example:
- If general
has given the ranking3 2 1 0
, then can stand next to , or , but not or . - If general
has given the ranking4 3 2 1 0
, then can stand next to , or , but not or .
Note that it is fine if one general is exactly in the middle of another's ranking.
The following figure illustrates sample 1. Here, general
You are given the rankings that the generals published. Your task is to arrange the generals
Input Specification
The first line contains the positive integer
The following
The ranking of general
Output Specification
Print a list of integers, an ordering of the numbers
It can be proven that a solution always exists. If there are multiple solutions, you may print any of them.
Constraints and Scoring
. for .
Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group.
Group | Score | Limits |
---|---|---|
1 | 11 | The ranking of general |
2 | 23 | The ranking of general |
3 | 29 | |
4 | 37 | No additional constraints. |
Sample Input 1
6
0
1 0
2 1 0
3 2 1 0
4 3 2 1 0
Sample Output 1
4 2 5 3 1 0
Sample Input 2
5
0
0 1
0 1 2
0 1 2 3
Sample Output 2
2 0 4 1 3
Sample Input 3
4
0
1 0
0 2 1
Sample Output 3
3 0 1 2
Comments