people numbered through stand in a line. Person () is -th from the left and holds a card . Each card is scissors (S), rock (R), or paper (P).
Two distinct people are adjacent when nobody stands between them. You may choose any two adjacent people for a match. Each match follows these rules.
R) beats scissors (S), scissors (S) beats paper (P), and paper (P) beats rock (R).Hold exactly matches so that one person remains as the champion. For each person, determine whether there is a sequence of matches that makes that person the champion.
The first line contains an integer . The second line contains a string of length . Its -th character is the card held by person and is one of the uppercase letters , , or ().
Print a string of length on the first line. Its -th character must be if person can become the champion and otherwise ().
S, R, and P.First match people 2 and 3. Their cards are the same, so either can win. If you choose person 2, they then defeat person 1 because paper beats rock.
If you choose person 3, they defeat person 1 in the same way.
Person 1 can never become the champion because rock cannot beat paper.
If people 2 and 3 play first, person 3 wins because scissors beats paper. Then person 1 defeats person 3 because rock beats scissors.
If people 1 and 2 play first, person 2 wins because paper beats rock. Then person 3 defeats person 2 because scissors beats paper.
Person 2 can never become the champion.
SRP| 5 | 43 | No additional constraints. |