-
Notifications
You must be signed in to change notification settings - Fork 0
/
2578.cpp
67 lines (58 loc) · 1.4 KB
/
2578.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <cstdio>
#include <set>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;++i)
int table[5][5];
bool call[5][5];
set<int> s; // 그어질 수 있는 빙고 줄에 번호를 매겨 사용한다! for excepting to count same lines
void paint(int n) {
rep(i,0,5) rep(j,0,5)
if(table[i][j] == n) {
call[i][j] = true; break;
}
}
void diagonal() {
bool found = true;
if(s.count(10) == 0) {
rep(i,0,5) if(!call[i][i]) { found = false; break; }
if(found) s.insert(10);
}
found = true;
if(s.count(11) == 0) {
rep(i,0,5) if(!call[4-i][i]) { found = false; break; }
if(found) s.insert(11);
}
}
void line() {
bool found = true;
// row
rep(i,0,5)
if(s.count(i) == 0) {
rep(j,0,5) if(!call[i][j]) { found = false; break; }
if(found) s.insert(i);
found = true;
}
// col
rep(i,0,5)
if(s.count(i+5) == 0) {
rep(j,0,5) if(!call[j][i]) { found = false; break; }
if(found) s.insert(i + 5);
found = true;
}
}
void check() {
diagonal(); line();
}
int main() {
rep(i,0,5) rep(j,0,5) call[i][j] = false;
int n, cnt = 0;
rep(i,0,5) rep(j,0,5) scanf("%d", &table[i][j]);
rep(i,0,25) {
scanf("%d", &n);
paint(n);
if(i > 6) {
check();
if(s.size() >= 3) { printf("%d", i+1); break; }
}
}
}