forked from tony9402/baekjoon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
75 lines (62 loc) · 1.29 KB
/
main.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
68
69
70
71
72
73
74
75
// Authored by : tony9402
// Co-authored by : -
// Link : http://boj.kr/6a874bc16cbc470eb3338e2ec945f180
#include<bits/stdc++.h>
using namespace std;
int board[5][5];
bool used[5][5];
bool bingo() {
int line = 0;
bool bingo = true;
for(int i=0;i<5;i++){
bingo = true;
for(int j=0;j<5;j++){
bingo &= used[i][j];
}
if(bingo) line ++;
bingo = true;
for(int j=0;j<5;j++){
bingo &= used[j][i];
}
if(bingo) line ++;
}
bingo = true;
for(int i=0;i<5;i++){
bingo &= used[i][i];
}
if(bingo) line++;
bingo = true;
for(int i=0;i<5;i++){
bingo &= used[4-i][i];
}
if(bingo) line++;
return line >= 3;
}
void marking(int number){
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
if(board[i][j] == number) {
used[i][j] = true;
return;
}
}
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
cin >> board[i][j];
}
}
for(int i=1;i<=25;i++){
int x;cin >> x;
marking(x);
if(bingo()){
cout << i;
return 0;
}
}
return 0;
}