-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP340.cpp
47 lines (42 loc) · 988 Bytes
/
P340.cpp
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
42
43
44
45
46
47
#include <iostream>
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
int main() {
int N, code[1009], codeCounts[9], a, aCounts[9];
for(int cas = 1; true; ++cas) {
std::cin >> N;
if(N == 0)
return 0;
std::cout << "Game " << cas << ":" << std::endl;
for(int i = 0; i < 9; ++i)
codeCounts[i] = 0;
for(int i = 0; i < N; ++i) {
std::cin >> code[i];
--code[i];
++codeCounts[code[i]];
}
while(true) {
bool allZero = true;
int strong = 0;
for(int i = 0; i < 9; ++i)
aCounts[i] = 0;
for(int i = 0; i < N; ++i) {
std::cin >> a;
if(a == 0)
continue;
allZero = false;
--a;
if(code[i] == a)
++strong;
++aCounts[a];
}
if(allZero)
break;
// Count all:
int all = 0;
for(int i = 0; i < 9; ++i)
all += MIN(aCounts[i],codeCounts[i]);
//std::cerr << "all: " << all << std::endl;
std::cout << " (" << strong << "," << (all-strong) << ")" << std::endl;
}
}
}