board = [] count = 0 for i in range(19): board.append(list(map(int, input().split()))) def side(y, x, num, dx, dy): if x == 19 or y == 19 or x < 0 or y < 0 or (y+dy) > 18 or (x+dx) > 18: return 0 if y == 14 and x == 14: print("test: ",y, x) if board[y][x] == num: return 1+side(y+dy,x+dx, num, dx, dy) else: return 0 stop = True for y in range(19): for x in range(19): if board[y][x] == 1 or board[y][x] == 2: i = board[y][x] li = [] count = side(y, x, i, 0, 1) li.append(count) count = side(y, x, i, 1, 0) li.append(count) count = side(y, x, i, 1, -1) li.append(count) count = side(y, x, i, 1, 1) li.append(count) if li.__contains__(5): print(board[y][x]) print(y+1,x+1) stop = False break if stop == False: break if stop: print(0) # # for i in range(10): # for j in range(10): # print([i, j], end=" ") # # print()
top of page
bottom of page