#P5782. [POI 2001] 和平委员会
[POI 2001] 和平委员会
Problem Description
According to the constitution, the Public Peace Committee of the Democratic Republic of Byteland should be established by a legislative procedure in the parliament. Unfortunately, conflicts between representatives of some parties make this difficult. The committee must satisfy the following conditions:
- Each party has exactly representative in the committee.
- If two representatives hate each other, then they cannot both be in the committee.
Each party has representatives in the parliament. The representatives are numbered from to . Representatives numbered and belong to the -th party.
Task: Write a program that reads the number of parties and the pairs of representatives who are unfriendly to each other, determines whether it is possible to establish the Peace Committee, and if so, outputs the list of its members.
Input Format
The first line contains two non-negative integers . They represent the number of parties and the number of unfriendly representative pairs , respectively.
The next lines each contain a pair of integers , meaning that representatives and hate each other.
Output Format
If it is impossible to establish the committee, output NIE.
If it is possible, output integers chosen from the range to , in increasing order, one per line. These numbers are the IDs of the representatives in the committee.
If the committee can be formed in multiple ways, your program may output any one of them.
3 2
1 3
2 4
1
4
5
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, , , .
Translated by ChatGPT 5