| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 2048 MB | 5 | 4 | 1 | 100.000% |
Dale and Chip are preparing the annual Fantastic Party for Chipmunks (FPC). This year, they say, it's much more than a big feast of nuts. In fact, they have prepared a game for their fellow friends. Like any chipmunk, they want their game to be predictable. There is no room for surprises. Last thing you would want is an angry losing chipmunk. Therefore, they will secretly plan the game such that everyone will win and lose exactly one time.
The game goes like this: a group of chipmunks is arranged in a circle. One of them will start the game by turning to their right neighbour and play a round of Rock Paper Scissors. Afterwards, the right neighbour turns to its right neighbour and plays a round of Rock Paper Scissors, and so on. The game ends when everyone has played with their right neighbour exactly once.
Dale has a list of chipmunks that will attend the party, and Chip knows for each of them what power (Rock, Paper, or Scissors) they will always play---% chipmunks are predictable, after all. Not everybody will be at the party at the same time, so they want to prepare the game for several sublists of the list of attendees. For every sublist, calculate the largest possible number of chipmunks picked from that sublist that can be arranged in a circle, such that everyone will be happy, no matter who starts the game.
A happy chipmunk is one that has won and lost exactly once.
The input consists of:
Rock", "Paper" or "Scissors"), which represents for every attendee what power they will always play.Output, for each of the $q$ sublists, the largest number of chipmunks that can be arranged into a circle such that every chipmunk is happy.
3 Rock Paper Scissors 3 1 3 1 2 2 3
3 0 0
8 Paper Rock Rock Rock Scissors Paper Scissors Paper 4 3 8 4 6 1 6 2 7
6 3 3 3