#P10643. [NordicOI 2022] 嬉皮爵士 Hipster Jazz
[NordicOI 2022] 嬉皮爵士 Hipster Jazz
Background
Translated from Nordic Olympiad in Informatics 2022 Hipster Jazz。If you find that the SPJ is broken, please contact the problem porter qvq。
。
Problem Description
In the jazz school, a new class has been formed。There are students in this class, with pairs of friendships。Each student has to choose one main instrument: piano, or saxophone。Of course, all students want to become creative jazz musicians, so they want to ensure that at least half of their friends choose a different instrument from their own。
The students realized that choosing instruments is difficult。So they came to you, hoping that you can choose a main instrument for each student and satisfy the condition above。
The testdata guarantees that at least one solution exists。
Input Format
The first line contains two positive integers , with meanings as described in the statement。
The next lines each contain two numbers , meaning that and are friends。
It is guaranteed that the same pair of friends will not be listed twice。It is guaranteed that at least one solution exists。
Output Format
Output a single line containing a string of characters。The -th character is P, meaning the -th student chooses piano; the -th character is S, meaning the -th student chooses saxophone。
3 3
1 2
1 3
2 3
PSP
5 6
1 2
1 3
1 5
2 4
3 5
4 5
SPPSP
6 9
1 4
1 5
1 6
2 4
2 5
2 6
3 4
3 5
3 6
PPPSSS
Hint
Constraints
- ;
- ;
- The same pair of friends will not be listed twice;
- At least one solution exists。
Subtasks
| Subtask ID | Score | Constraint |
|---|---|---|
| Every pair of students are friends | ||
| There exists a solution where every pair of friends choose different instruments | ||
| No additional constraints |
Translated by ChatGPT 5