board = []
coord = []
memo = []
winner = []
rightcoord = []
count = 0
check = False
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 or (y+dy) > 18 or (x+dx) > 18:
return 0
if data in memo:
return 0
if board[y+dy][x+dx] == num and not winner:
memo.append(data)
rightcoord.append([y+1,x+1])
#print(rightcoord, board[y+dy][x+dx])
return 1+side([y+dy,x+dx], num, dx, dy)
else:
return 0
def reset(count, num): # 메모를 위한 리셋?
global memo
global winner
global rightcoord
memo = []
if count != 4:
count = 0
else:
winner.append(num)
winner.append(count)
if not winner:
rightcoord = []
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(winner[0])
rightcoord.sort()
print(rightcoord)
#print(rightcoord[0][0],rightcoord[0][1])
else:
print(0)
#
# for i in range(10):
# for j in range(10):
# print([i, j], end=" ")
#
# print()
top of page
기능을 테스트하려면 라이브 사이트로 이동하세요.
211020
211020
댓글 0개
좋아요
댓글(0)
bottom of page