#P10247. Pairing Pairs
Pairing Pairs
Background
This problem uses the original contest testdata. If you want to test an solution, you can refer to the enhanced version.
Problem Description
You are given pairs (guaranteed that , and all pairs are pairwise distinct). For each , find an index such that the four numbers are all distinct from each other, or report that such a does not exist.
Input Format
The first line contains two positive integers , indicating the range of numbers in the pairs and the number of pairs.
The next lines each contain two positive integers , representing the -th pair.
Output Format
Output one line with non-negative integers. The -th integer is the you found for this . If no such exists, output .
If there are multiple valid , output any one of them.
6 5
1 2
2 3
1 3
2 5
3 6
5 0 4 5 1
Hint
[Sample Explanation]
The answer is not unique. For example, when :
- can also be , because the four numbers are all distinct. So outputting
5 0 4 3 1can also pass. - However, cannot be , because among there are repeated numbers.
[Constraints]
This problem uses bundled judging. Specifically, you can get the score of a subtask only if you pass all test points in that subtask.
| Subtask ID | Special property | Score | ||
|---|---|---|---|---|
| Random testdata | ||||
The specific generation process for subtask : first I specify a set of , then repeat the following process times:
- Draw from , then draw from .
- If , then increase by ; otherwise swap .
- Check whether the pair has appeared before. If yes, go back to the first step.
- Output .
For all data, it is guaranteed that , and .
Translated by ChatGPT 5