from _typeshed import WriteableBuffer from typing import type_check_only board = [] coord = [] memo = [] winner = [] count = 0 for i in range(19): # 바둑판 생성 board.append(list(map(int, input().split()))) def findcorrd(num): # 휜돌 or 흑돌 찾기 for y in range(19): for x in range(19): if board[y][x] == num: coord.append([y, x]) def side(data, num, dx, dy): # 5개인지 찾기 y = data[0] x = data[1] if x == 19 or y == 19 or x < 0 or y < 0: return 0 if data in memo: return 0 if board[y+dy][x+dx] == num: memo.append(data) return 1+side([y+dy,x+dx], num, dx, dy) else: return 0 def reset(count, num): # 메모를 위한 리셋? global memo global winner memo = [] if count != 4: count = 0 else: winner.append(num) winner.append(count) def main(num): global memo global count findcorrd(num) for i in coord: count = side(i, num, 0, 1) reset(count,num) count = side(i, num, 1, 0) reset(count,num) count = side(i, num, 1, 1) reset(count,num) count = side(i, num, 1, -1) main(1) main(2) if bool(winner): print(0) else: print(winner[0])
top of page
bottom of page