File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 10.4 MB, 시간: 11.30 ms
7+ 메모리: 9.48 MB, 시간: 10.45 ms
88
99### 구분
1010
1616
1717### 제출 일자
1818
19- 2025년 03월 07일 17:35:12
19+ 2025년 12월 31일 13:49:06
2020
2121### 문제 설명
2222
Original file line number Diff line number Diff line change 22
33def solution (maps ):
44 n , m = len (maps ), len (maps [0 ])
5- dx = [- 1 , 1 , 0 , 0 ]
6- dy = [0 , 0 , - 1 , 1 ]
7-
85 visited = [[False ] * m for _ in range (n )]
96 visited [0 ][0 ] = True
107
11- q = deque ([(0 , 0 , 1 )])
8+ q = deque ([(1 , 0 , 0 )])
9+ dx = [- 1 , 1 , 0 , 0 ]
10+ dy = [0 , 0 , - 1 , 1 ]
1211
1312 while q :
14- x , y , dist = q .popleft ()
13+ cnt , x , y = q .popleft ()
1514 if x == n - 1 and y == m - 1 :
16- return dist
15+ return cnt
1716
1817 for i in range (4 ):
1918 nx = x + dx [i ]
2019 ny = y + dy [i ]
20+
2121 if 0 <= nx < n and 0 <= ny < m and not visited [nx ][ny ] and maps [nx ][ny ] == 1 :
22- q .append ((nx , ny , dist + 1 ))
22+ q .append ((cnt + 1 , nx , ny ))
2323 visited [nx ][ny ] = True
24+
25+
2426 return - 1
You can’t perform that action at this time.
0 commit comments