[20260203] BOJ / G5 / 랭퍼든 수열쟁이야!! / 이준희#1876
Merged
ShinHeeEul merged 1 commit intomainfrom Feb 3, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/15918
🧭 풀이 시간
70분
👀 체감 난이도
✏️ 문제 설명
랭퍼드 수열은 다음 조건을 만족하는 길이 2n의 수열입니다.
1 이상 n 이하의 자연수가 각각 두 개씩 들어 있다.
두 개의 1 사이에는 정확히 1개의 수가 있다.
두 개의 2 사이에는 정확히 2개의 수가 있다.
...
두 개의 n 사이에는 정확히 n개의 수가 있다.
n이 주어졌을 때 길이 2n의 랭퍼드 수열의 개수를 구하는 문제입니다.
이 때 n과 x, y가 주어지는데 x번째와 y번째의 순서는 같다는 조건이 추가되었습니다.
🔍 풀이 방법
백트래킹을 통해서 풀었습니다.
1번째 칸부터 2n번째 칸까지 순회하며 값을 넣었습니다.
이 때의 규칙은 i 번째에 2를 넣는다면 i + 2 + 1 번째에 2가 들어가야 합니다.(랭퍼드 수열의 조건)
이러한 규칙을 따라서 입력 -> 백트래킹을 반복하다보면 답을 구할 수 있습니다.
⏳ 회고
문제 푸는 방법을 떠올리는 데 시간이 많이 걸렸습니다.
처음보는 유형의 문제였던 것 같습니다.