-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbaekjoon_3085.py
45 lines (37 loc) · 1.11 KB
/
baekjoon_3085.py
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
def max_board(y, x):
answer = 1
for yy in [y, y+1]:
if yy >= N:
continue
temp = 1
for xx in range(N-1):
if board[yy][xx] == board[yy][xx+1]:
temp += 1
else:
temp = 1
answer = max(temp, answer)
for xx in [x, x+1]:
if xx >= N:
continue
temp = 1
for yy in range(N-1):
if board[yy][xx] == board[yy+1][xx]:
temp += 1
else:
temp = 1
answer = max(temp, answer)
return answer
N = int(input())
board = [list(input()) for _ in range(N)]
result = 0
for y in range(N):
for x in range(N):
if x+1 < N:
board[y][x], board[y][x+1] = board[y][x+1], board[y][x]
result = max(result, max_board(y, x))
board[y][x], board[y][x+1] = board[y][x+1], board[y][x]
if y+1 < N:
board[y][x], board[y+1][x] = board[y+1][x], board[y][x]
result = max(result, max_board(y, x))
board[y][x], board[y+1][x] = board[y+1][x], board[y][x]
print(result)