-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재 위치에 대한 관점으로 백 트래킹을 진행하였을 때 지금처럼 진행 될 수 있음을 알게된 것 같아서 도움이 많이 되었습니다! 고생하셨어요 수민님!
nxt_idx += 1 | ||
|
||
# 현재 위치 방문처리 | ||
visited[cur_x][cur_y] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
방문처리를 다음에 탐색할 영역이 아닌 현재 방문한 위치에 대해서 방문 처리 및 방문 처리 해제를 해주는 과정이 인상 깊네요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 사실 ny와 nx를 다룰 때 방문 처리를 하는게 익숙해서 잘 와닿지 않았던 것 같아요! 하지만 이렇게 훨씬 깔끔하게 구성할 수 있다는 것을 알았습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
백트래킹 문제를 풀 때 여러 방법으로 풀어서 수민님처럼 깔끔하게 풀이하는 노하우 익혀보도록 하겠습니다! 고생하셨습니다 수민님~
nxt_idx += 1 | ||
|
||
# 현재 위치 방문처리 | ||
visited[cur_x][cur_y] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 사실 ny와 nx를 다룰 때 방문 처리를 하는게 익숙해서 잘 와닿지 않았던 것 같아요! 하지만 이렇게 훨씬 깔끔하게 구성할 수 있다는 것을 알았습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제 풀이에서 조금 더 직관적인 풀이인것 같아요 ..ㅎ
잘 이해할 수 있었습니다 감사합니다~!
PR Summary
풀이시간: 40분
<input>
n: 격자의 크기(2 ≤ n ≤ 4)
m: 순서대로 방문해야 하는 칸의 수(2 ≤ m ≤ n^2)
n개의 수(0 or 1)
방문해야할 m개의 칸 (x, y)가 주어진다
<solution>
n과 m이 매우 작기 때문에 DFS를 통해 모든 경우의 수를 확인한다.(브루트 포스)
이 때, 더 이상 다음 칸으로 이동할 수 없다면 탐색을 포기한다.(백트래킹)
<시간복잡도>
O(N^2)