[20250722] BOJ / G4 / 좋은수열 / 이인희 #526
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://www.acmicpc.net/problem/2661
🧭 풀이 시간
35 분
👀 체감 난이도
✏️ 문제 설명
1, 2,3으로만 이뤄진 수열이 있는데, 이 중, 임의의 길이의 인접한 두 개의 부분 수열이 동일한 것이 있으면, 그 수열을 나쁜 수열이라고 부른다. 그렇지 않은 수열은 좋은 수열이다.길이가 N인 좋은 수열들을 N자리의 정수로 보아 그중 가장 작은 수를 나타내는 수열을 출력하는 문제.
🔍 풀이 방법
⏳ 회고
이미 진행중이던 노드를 모두 끝내버리게 하기 위해서
found를 생각해내는 것이 생소하였다. dfs에서 백트래킹을 할 때, 특정 조건이 되면 남은 노드들을 모두 종료시키는 로직은 전역변수로 found를 두고, 정답을 찾을 때, 이를 true로 바꾸는 로직과, dfs함수의 맨 처음에 found조건을 둬야한다는 것을 기억하자