#P10643. [NordicOI 2022] 嬉皮爵士 Hipster Jazz

    ID: 12121 远端评测题 1000ms 1024MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2022Special Judge随机调整构造NordicOI(北欧)

[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。

1s,1G\texttt{1s,1G}

Problem Description

In the jazz school, a new class has been formed。There are NN students in this class, with MM 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 N,MN, M, with meanings as described in the statement。

The next MM lines each contain two numbers a,ba, b, meaning that aa and bb 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 NN characters。The ii-th character is P, meaning the ii-th student chooses piano; the ii-th character is S, meaning the ii-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

  • 1N2001 \le N \le 200
  • 0MN(N1)20 \le M \le \dfrac{N(N-1)}{2}
  • The same pair of friends will not be listed twice;
  • At least one solution exists。

Subtasks

Subtask ID Score Constraint
11 1010 Every pair of students are friends
22 1515 N15N \le 15
33 2525 There exists a solution where every pair of friends choose different instruments
44 5050 No additional constraints

Translated by ChatGPT 5