작성
·
141
0
sys.setrecursionlimit(10**6)
def DFS(x, y, w):
ch[x][y] = 1
for i in range(4):
a = x + dx[i]
b = y + dy[i]
if 0 <= a < n and 0 <= b < n and tmp[a][b] > w and ch[a][b] == 0:
DFS(a, b, w)
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]
n = int(input())
tmp = [list(map(int, input().split())) for _ in range(n)]
count = 0
res = 0
for i in range(100):
count = 0
ch = [[0] * n for _ in range(n)]
for j in range(n):
for k in range(n):
if ch[j][k] == 0 and tmp[j][k] > i:
count += 1
DFS(j, k, i)
if res < count:
res = count
if count == 0:
break
print(res)
5번은 통과하는데 4번만 시간초과합니다
컴퓨터 문제일까요??