Skip to content

Commit f63dd39

Browse files
committed
[BOJ] #2578.빙고 / 실버4 / 30(X)
1 parent f0ebdf7 commit f63dd39

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
board = [list(map(int, input().split())) for _ in range(5)]
5+
num = [int(x) for _ in range(5) for x in input().split()]
6+
7+
visited = [[False] * 5 for _ in range(5)]
8+
bingo = 0
9+
10+
def update_visited(num, board, visited):
11+
for row in range(5):
12+
for col in range(5):
13+
if board[row][col] == num:
14+
visited[row][col] = True
15+
16+
def check_bingo(visited):
17+
bingo = 0
18+
19+
# 가로줄 검사
20+
for row in range(5):
21+
if all(visited[row][col] for col in range(5)):
22+
bingo += 1
23+
24+
# 세로줄 검사
25+
for col in range(5):
26+
if all(visited[row][col] for row in range(5)):
27+
bingo += 1
28+
29+
# 대각선 검사
30+
if all(visited[i][i] for i in range(5)):
31+
bingo += 1
32+
if all(visited[i][4-i] for i in range(5)):
33+
bingo += 1
34+
35+
return bingo
36+
37+
38+
for idx, i in enumerate(num, start=1):
39+
update_visited(i, board, visited)
40+
if check_bingo(visited) >= 3:
41+
print(idx)
42+
break

0 commit comments

Comments
 (0)