Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

[2023-10-09] sumin #313 #327

Merged
merged 1 commit into from
Oct 9, 2023
Merged

[2023-10-09] sumin #313 #327

merged 1 commit into from
Oct 9, 2023

Conversation

ksumini
Copy link
Contributor

@ksumini ksumini commented Oct 9, 2023

PR Summary

풀이시간: 40분

<input>
n: 격자의 크기(2 ≤ n ≤ 4)
m: 순서대로 방문해야 하는 칸의 수(2 ≤ m ≤ n^2)

n개의 수(0 or 1)

  • 0: 빈 칸
  • 1: 벽

방문해야할 m개의 칸 (x, y)가 주어진다

  • 주어진 칸에 벽이 있는 경우능 없고, 중복도 없다.

<solution>
n과 m이 매우 작기 때문에 DFS를 통해 모든 경우의 수를 확인한다.(브루트 포스)
이 때, 더 이상 다음 칸으로 이동할 수 없다면 탐색을 포기한다.(백트래킹)

<시간복잡도>
O(N^2)

Copy link
Member

@Woo-Yeol Woo-Yeol left a 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

방문처리를 다음에 탐색할 영역이 아닌 현재 방문한 위치에 대해서 방문 처리 및 방문 처리 해제를 해주는 과정이 인상 깊네요!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 사실 ny와 nx를 다룰 때 방문 처리를 하는게 익숙해서 잘 와닿지 않았던 것 같아요! 하지만 이렇게 훨씬 깔끔하게 구성할 수 있다는 것을 알았습니다!

Copy link
Contributor

@zsmalla zsmalla left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 사실 ny와 nx를 다룰 때 방문 처리를 하는게 익숙해서 잘 와닿지 않았던 것 같아요! 하지만 이렇게 훨씬 깔끔하게 구성할 수 있다는 것을 알았습니다!

Copy link
Contributor

@limstonestone limstonestone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제 풀이에서 조금 더 직관적인 풀이인것 같아요 ..ㅎ
잘 이해할 수 있었습니다 감사합니다~!

@ksumini ksumini merged commit d6e9ba0 into main Oct 9, 2023
@ksumini ksumini deleted the sumin-#313 branch October 9, 2023 13:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Softeer] [HSAT 7회 정기 코딩 인증평가 기출] 순서대로 방문하기
4 participants