| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 15 초 (추가 시간 없음) | 1024 MB | 10 | 3 | 3 | 75.000% |
The city of Circleburg has a large circular street with N consulates along it. The consulates are numbered 1, 2, ..., N in clockwise order.
Today G guests, numbered 1, 2, ..., G will drive along the circular street for M minutes. Each guest is either a clockwise guest (denoted by the character C) or an anti-clockwise guest (denoted by the character A).
The i-th guest starts at the consulate numbered Hi and at the end of each minute will drive to an adjacent consulate. The i-th guest starts at the j-th consulate. If that guest is:
Each consulate will only remember the guest that visited them last. If there are multiple guests who visited last, then the consulate will remember all of those guests.
For each guest, determine how many consulates will remember them.
The first line of the input gives the number of test cases, T. T test cases follow. Each testcase begins with a line containing the three integers N, G and M, which are the number of consulates, the number of guests and the number of minutes respectively. Then, G lines follow. The i-th line contains the integer Hi followed by a single character; C if the i-th guest is a clockwise guest or A if the i-th guest is an anti-clockwise guest.
For each test case, output one line containing Case #x: y1 y2 ... yG, where x is the test case number (starting from 1) and yi is the number of consulates that remember the i-th guest.
4 5 3 2 5 C 2 A 1 A 2 4 0 1 A 1 C 1 A 1 C 3 2 10 3 C 2 A 6 1 6 4 A
Case #1: 2 2 1 Case #2: 1 1 1 1 Case #3: 2 2 Case #4: 6
In the first sample case, there are N = 5 consulates, G = 3 guests, who will drive for M = 2 minutes.
Thus the answer should be 2, 2, 1 for the 1st, 2nd and 3rd guests respectively.
In the second sample case, there are N = 2 consulates, G = 4 guests, who will drive for M = 0 minutes.
Thus the answer should be 1, 1, 1, 1 for the 1st, 2nd, 3rd and 4th guests respectively.
In the third sample case, there are N = 3 consulates, G = 2 guests, who will drive for M = 10 minutes.
Thus the answer should be 2, 2 for the 1st and 2nd guests respectively.
In the fourth sample case, there is only one guest. This guest visits all the consulates eventually, so is remembered by all of them. Thus the answer is 6.
Contest > Google > Kick Start > Google Kick Start 2019 > Round D B번