-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbj_2578.cpp
More file actions
73 lines (61 loc) · 1.34 KB
/
bj_2578.cpp
File metadata and controls
73 lines (61 loc) · 1.34 KB
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
68
69
70
71
72
73
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
int main() {
int bingo[6][6] = {};
cin.tie(NULL);
cout.tie(NULL);
ios_base::sync_with_stdio(false);
map<int, pair<int, int> > M;
queue<int> Q;
for(int i = 0; i<5; i++) {
for(int j = 0; j<5; j++) {
int tar;
cin >> tar;
bingo[i][j] = tar;
M[tar] = make_pair(i, j);
}
}
for(int i = 0; i<25; i++) {
int ret;
cin >> ret;
Q.push(ret);
}
int cnt = 1;
int num = 0;
int tri_one = 0;
int tri_two = 0;
while(!Q.empty()) {
int turn = Q.front();
Q.pop();
pair<int, int> X = M[turn];
bingo[5][X.second]++;
bingo[X.first][5]++;
if(X.second == X.first) {
tri_one++;
if(tri_one == 5) {
num++;
}
}
if(X.second + X.first == 4) {
tri_two++;
if(tri_two == 5) {
num++;
}
}
if(bingo[5][X.second] == 5) {
num++;
}
if(bingo[X.first][5] == 5) {
num++;
}
if(num >= 3) {
cout << cnt << "\n";
return 0;
}
cnt++;
}
}