failed
확실히 알았다 .. 나 완탐 약하구나..
import sys
input = sys.stdin.readline
n = int(input().rstrip())
candies = [list(input().rstrip()) for _ in range(n)]
dx = [0, 1]
dy = [1, 0]
res = 0
def check():
max_cnt = 1
for i in range(n):
cnt = 1
for j in range(1, n):
if candies[i][j] == candies[i][j-1]:
cnt += 1
else:
cnt = 1
max_cnt = max(max_cnt, cnt)
cnt = 1
for j in range(1, n):
if candies[j][i] == candies[j-1][i]:
cnt += 1
else:
cnt = 1
max_cnt = max(max_cnt, cnt)
return max_cnt
for i in range(n):
for j in range(n):
for d in range(2):
nx = i + dx[d]
ny = j + dy[d]
if (0 <= nx < n) and (0 <= ny < n):
candies[i][j] = candies[nx][ny]
res = max(res, check())
candies[nx][ny] = candies[i][j]
print(res)
import sys
input = sys.stdin.readline
n = int(input().rstrip())
candies = [list(input().rstrip()) for _ in range(n)]
dx = [0, 1]
dy = [1, 0]
res = 0
def check():
max_cnt = 1
for i in range(n):
cnt = 1
for j in range(1, n):
if candies[i][j] == candies[i][j-1]:
cnt += 1
else:
cnt = 1
max_cnt = max(max_cnt, cnt)
cnt = 1
for j in range(1, n):
if candies[j][i] == candies[j-1][i]:
cnt += 1
else:
cnt = 1
max_cnt = max(max_cnt, cnt)
return max_cnt
for i in range(n):
for j in range(n):
for d in range(2):
nx = i + dx[d]
ny = j + dy[d]
if (0 <= nx < n) and (0 <= ny < n):
candies[i][j], candies[nx][ny] = candies[nx][ny], candies[i][j]
res = max(res, check())
candies[i][j], candies[nx][ny] = candies[nx][ny], candies[i][j]
print(res)
바보같이 바꿀 때 제대로 안바꿔줬다...하아