NOIP2014 Day1 T1(模拟)

特别水,直接模拟就好,简化代码用了一个邻接表来存胜负关系

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
const int MAXN = 200 + 5;
const int G[10][10] = {
{ 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, A[MAXN], B[MAXN];
void clean() {}
void init() {
clean();
for (int i=0;i<na;i++) scanf("%d", &A[i]);
for (int i=0;i<nb;i++) scanf("%d", &B[i]);
}
void solve() {
int ansa=0,ansb=0;
for (int i=0;i<n;i++) {
if (G[A[i%na]][B[i%nb]]>=0) {
ansa += G[A[i%na]][B[i%nb]];
} else ansb += -G[A[i%na]][B[i%nb]];
}
printf("%d %d\n", ansa, ansb);
}
int main() {
#ifndef ONLINE_JUDGE
freopen("1.in", "r", stdin);freopen("1.out", "w", stdout);
#endif
while (scanf("%d%d%d", &n ,&na, &nb)==3) init(), solve();
return 0;
}

------ 本文结束 ------