洛谷 P1328 生活大爆炸版石头剪刀布
/*
P1328 生活大爆炸版石头剪刀布
*/
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
int rule[5][5] = { // 初始化
{0, -1, 1, 1, -1},
{1, 0, -1, 1, -1},
{-1, 1, 0, -1, 1},
{-1, -1, 1, 0, 1},
{1, 1, -1, -1, 0}
};
int n, na, nb; cin >> n >> na >> nb;
int a[na], b[nb];
for(int i = 0; i < na; i++) scanf("%d", &a[i]);
for(int i = 0; i < nb; i++) scanf("%d", &b[i]);
int cnta = 0, cntb = 0; // 周期
int ansa = 0, ansb = 0; // 计数
for(int i = 0; i < n; i++) {
int judge = rule[a[cnta++ % na]][b[cntb++ % nb]];
if(judge > 0) {
// cout << "A WIN: " << (cnta-1) % na << ", " << (cntb-1) % nb << "| " << judge << endl;
ansa ++;
} else if(judge < 0) {
// cout << "B WIN: " << (cnta-1) % na << ", " << (cntb-1) % nb << "| " << judge << endl;
ansb ++;
}
}
cout << ansa << " " << ansb << endl;
return 0;
}