#P7748. [COCI 2013/2014 #2] VOLIM
[COCI 2013/2014 #2] VOLIM
Description
There are people sitting in a circle, as shown in the figure.

One of them is holding a box, and the box will explode seconds after the game starts.
The host will ask the box holder questions. The box holder may do one of the following:
- If they skip or answer incorrectly, the host will continue by asking the next question.
- If they answer correctly, the box holder passes the box to the first person on their left. That person becomes the new box holder.
Now you know, for each question, the time the respondent spent and whether the answer was correct.
Given the initial box holder’s number at the start of the game and the number of questions, find the number of the person holding the box when it explodes.
The time to pass the box and the time between two questions are ignored. The testdata guarantees that when the box explodes, the box is in someone’s hands, and the questions have not all been asked.
Input Format
The first line contains an integer , the number of the person holding the box at the start of the game.
The second line contains an integer , the number of questions.
The next lines each contain an integer and a character, representing the time spent answering that question and the result:
- The character is , meaning the answer is correct.
- The character is , meaning the answer is incorrect.
- The character is , meaning the question is skipped.
Output Format
Output one integer in a single line: the number of the person holding the box when it explodes.
1
5
20 T
50 T
80 T
50 T
30 T
5
3
5
100 T
100 N
100 T
100 T
100 N
4
5
6
70 T
50 P
30 N
50 T
30 P
80 T
7
Hint
Constraints
For of the testdata, , .
Source
This problem is translated from COCI2013-2014 CONTEST 2 T1 VOLIM.
According to the original problem’s scoring settings, the full score for this problem is points.
Translated by ChatGPT 5
京公网安备 11011102002149号