File tree Expand file tree Collapse file tree
codetree.ai 삼성전자 2025 하반기 오후 1번 문제 AI 로봇청소기 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,19 +27,16 @@ def solve():
2727
2828 candidates = []
2929 queue = deque ([[0 , robot_sr , robot_sc ]])
30+ visited [robot_sr ][robot_sc ] = True
3031
3132 while queue :
3233 queue_next = deque ()
3334
3435 while queue :
3536 depth , sr , sc = queue .popleft ()
36-
37- if visited [sr ][sc ] == False : # 인접한 칸에서오는 중복 방문 제거
38- if dt [sr ][sc ] > 0 :
39- candidates .append ([sr , sc ])
40-
41- visited [sr ][sc ] = True
42- queue_next .append ([depth , sr , sc ])
37+ if dt [sr ][sc ] > 0 :
38+ candidates .append ([sr , sc ])
39+ queue_next .append ([depth , sr , sc ])
4340
4441 if len (candidates ) > 0 :
4542 break
@@ -53,6 +50,7 @@ def solve():
5350 if 0 <= nr < N and 0 <= nc < N and visited [nr ][nc ] == False :
5451 if dt [nr ][nc ] >= 0 : # 빈칸이거나 먼지가 있거나
5552 queue .append ([depth + 1 , nr , nc ])
53+ visited [nr ][nc ] = True
5654
5755 if len (candidates ) == 0 :
5856 robots_next .append ([robot_sr , robot_sc ])
You can’t perform that action at this time.
0 commit comments