#P1328. [NOIP 2014 提高组] 生活大爆炸版石头剪刀布

[NOIP 2014 提高组] 生活大爆炸版石头剪刀布

Description

Rock-paper-scissors is a common hand game: rock beats scissors, scissors beat paper, and paper beats rock. If two players show the same gesture, it is a draw. In Season 2, Episode 8 of “The Big Bang Theory,” an upgraded version of the game appears.

On top of the traditional rock-paper-scissors game, the upgraded version adds two new gestures:

Spock: one of the main characters in Star Trek.

Lizard: a villain in Star Trek.

The win–loss relationships among the five gestures are shown in Table 1. The table lists the result of player A versus player B.

Now, Xiao A and Xiao B are trying this upgraded hand game. It is known that their moves follow periodic patterns, though their period lengths may differ. For example: if Xiao A plays with the period 石头-布-石头-剪刀-蜥蜴人-斯波克 of length 66, then his sequence of moves is 石头-布-石头-剪刀-蜥蜴人-斯波克-石头-布-石头-剪刀-蜥蜴人-斯波克-...; and if Xiao B plays with the period 剪刀-石头-布-斯波克-蜥蜴人 of length 55, then his sequence of moves is 剪刀-石头-布-斯波克-蜥蜴人-剪刀-石头-布-斯波克-蜥蜴人-....

They will play a total of NN rounds. In each round, the winner gets 11 point, the loser gets 00 points; in a draw, both get 00 points. Please compute the scores of the two players after NN rounds.

Input Format

The first line contains three integers: N,NA,NBN, N_A, N_B, representing the total number of rounds, the period length of Xiao A’s moves, and the period length of Xiao B’s moves, respectively. The numbers are separated by a space.

The second line contains NAN_A integers representing Xiao A’s pattern, and the third line contains NBN_B integers representing Xiao B’s pattern. Here, 00 denotes 剪刀, 11 denotes 石头, 22 denotes , 33 denotes 蜥蜴人, and 44 denotes 斯波克. The numbers are separated by a space.

Output Format

Output a single line containing two integers separated by a space, representing the scores of Xiao A and Xiao B, respectively.

10 5 6
0 1 2 3 4
0 3 4 2 1 0

6 2

9 5 5
0 1 2 3 4
1 0 3 2 4

4 4

Hint

For 100%100\% of the testdata, 0<N200,0<NA200,0<NB2000 < N \leq 200, 0 < N_A \leq 200, 0 < N_B \leq 200.

Translated by ChatGPT 5