| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 서브태스크 참고 (추가 시간 없음) | 1024 MB | 96 | 37 | 27 | 37.500% |
Ada has decided that this year, she will take part in the annual marathon that takes place in her city. Since this is the first time she would be running such a long distance, she has decided to start practising for it by running in the circular track of length $\mathbf{L}$ units near her house.
Ada wants to focus only on running, so she decides to use a machine to count the number of laps she has run. The machine is placed at the starting line of the circular track and starts the count from 0ドル$. Every time Ada arrives at the starting line running in the same direction as the last time she departed from the starting line, the machine increases the number of laps that Ada has run by 1ドル$. If she crosses the starting line or changes direction at the starting line, the machine considers the new direction as the direction she last touched the starting line. The machine only remembers the last direction in which Ada touched the starting line. During a lap, Ada can change directions any number of times, but as long as she eventually touches the starting line in the same direction as she last touched it, the count of laps in the machine increases by 1ドル$.
This is the first time Ada has practised running long distances, so she cannot run continuously. She runs some distance, then takes a break to regain her energy. However, when she starts running again after taking a break, she cannot remember which direction she was running in previously. So she picks one of the directions, clockwise or anticlockwise, and starts running from the same position where she stopped.
Ada begins at the starting line and is initially facing in the direction of her first run. She runs a total of $\mathbf{N}$ times, taking breaks in between. Given the information of the distance $\mathbf{D_i}$ units Ada has run, and the direction $\mathbf{C_i}$ she has taken (clockwise or anticlockwise) when she ran the $i$-th time, for all $i$ from 1,ドル \dots, \mathbf{N},ドル can you tell the number of laps that would be reported by the machine at the end?
The first line of the input gives the number of test cases, $\mathbf{T}$. $\mathbf{T}$ test cases follow.
The first line of each test case contains two positive integers $\mathbf{L}$ and $\mathbf{N},ドル the length of the circular track in units, and the number of times Ada has run respectively.
The next $\mathbf{N}$ lines describe Ada's runs. The $i$-th line contains a positive integer $\mathbf{D_i}$ and a character $\mathbf{C_i},ドル the distance in units Ada has run and the direction she has taken (clockwise or anticlockwise) respectively during the $i$-th run. $\mathbf{C_i}$ will always be either 'C' (denoting clockwise direction) or 'A' (denoting anticlockwise direction).
For each test case, output one line containing Case #x: y, where $x$ is the test case number (starting from 1) and $y$ is a non negative integer denoting the number of laps reported by the machine at the end.
시간 제한: 20 초
'C', for all 1ドル \le i \le \mathbf{N}$.시간 제한: 40 초
'C' or 'A', for all 1ドル \le i \le \mathbf{N}$.2 5 3 8 C 3 C 6 C 8 4 5 C 9 C 8 C 20 C
Case #1: 3 Case #2: 5
In Sample Case #1, the length of the circular track is 5ドル$ units. Ada is facing the clockwise direction in the beginning.
In Sample Case #2, the length of the circular track is 8ドル$ units. Ada is facing the clockwise direction in the beginning.
3 5 3 8 C 4 A 5 C 4 5 2 C 8 A 3 A 5 C 8 A 4 3 3 C 2 A 5 C
Case #1: 1 Case #2: 5 Case #3: 1
In Sample Case #1, the length of the circular track is 5ドル$ units. Ada is facing the clockwise direction in the beginning.
In Sample Case #2, the length of the circular track is 4ドル$ units. Ada is facing the clockwise direction in the beginning.
In Sample Case #3, the length of the circular track is 4ドル$ units. Ada is facing in the clockwise direction in the beginning.
Contest > Google > Kick Start > Google Kick Start 2022 > Round H A번