Skip to content

Commit 899ec3b

Browse files
committed
bfs
1 parent 0661c43 commit 899ec3b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

BaekJoon/BFS_2589.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ def bfs(x, y):
2222
c[x][y] = 1
2323
maxN = 0
2424
while q:
25-
[x, y] = q.popleft()
25+
x, y = q.popleft()
2626
for i in range(4):
2727
Nx, Ny = x+dx[i], y+dy[i]
28-
if 0 < Nx < N and 0 < Ny < M and maze[Nx][Ny] == 'L':
28+
if 0 <= Nx < N and 0 <= Ny < M and maze[Nx][Ny] == 'L' and c[Nx][Ny] == 0:
2929
q.append([Nx, Ny])
30-
maze[Nx][Ny] = 'W'
3130
c[Nx][Ny] = c[x][y]+1
3231
maxN = max(c[Nx][Ny], maxN)
3332
return maxN - 1
@@ -36,6 +35,6 @@ def bfs(x, y):
3635
for i in range(N):
3736
for j in range(M):
3837
if maze[i][j] == 'L':
39-
maxCount = (maxCount, bfs(i, j))
38+
maxCount = max(maxCount, bfs(i, j))
4039

4140
print(maxCount)

check.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@
55
str = 'sre'
66
print(str[-1])
77

8-
print(1<<0)
8+
print(1<<0)
9+
a, b = 1, 2
10+
print(a)
11+
print(b)

0 commit comments

Comments
 (0)