Baseball Game (APCS 2016-10 Expert)
1.0s 256MNine players bat cyclically in the order \(1,2,\ldots,9,1,2,\ldots\). Their batting results are supplied separately for each player. Reconstruct chronological order and simulate the score.
For 1B, 2B, or 3B, the batter and every existing runner advance by \(1\), \(2\), or \(3\) bases respectively. On HR, the batter and all runners reach home. Every runner reaching home scores one run. Each of SO, FO, and GO adds one out without advancing runners. After every third out, clear all bases and continue with the next batter. Initially the bases are empty and both score and out count are zero.
Given \(b\), find the total score when the \(b\)-th out occurs. Ignore later batting results.
Input Format
The input has ten lines. For each of the nine players in order, one line contains the batting count \(a_i\) followed by that player’s \(a_i\) result strings in chronological order. The tenth line contains \(b\).
Output Format
Print the total score when the \(b\)-th out occurs.
Constraints
\(1\le a_i\le5\), \(1\le b\le27\). Every result is one of 1B, 2B, 3B, HR, SO, FO, GO. The records follow the cyclic batting order without missing turns and include at least \(b\) outs.
Scoring
- 20 points: Only
HRandSOoccur. - 20 points: The only hit type is
1B, and \(b=3\). - 20 points: \(b=3\).
- 40 points: No additional restrictions.
Each scored test is worth 5 points.
Sample Input 1
5 1B 1B FO GO 1B
5 1B 2B FO FO SO
4 SO HR SO 1B
4 FO FO FO HR
4 1B 1B 1B 1B
4 GO GO 3B GO
4 1B GO GO SO
4 SO GO 2B 2B
4 3B GO GO FO
3
Sample Output 1
0
Sample Input 2
5 1B 1B FO GO 1B
5 1B 2B FO FO SO
4 SO HR SO 1B
4 FO FO FO HR
4 1B 1B 1B 1B
4 GO GO 3B GO
4 1B GO GO SO
4 SO GO 2B 2B
4 3B GO GO FO
6
Sample Output 2
5
Source
APCS 2016-10 public archive version: c297。
Log in to write and submit code.
Log in