[20251219] BOJ / P5 / 레몬컵 출제하기 / 권혁준 #1712
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/34253
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
문제 N개가 출제된 순서대로 주어진다. 각 문제는 길이 K인 이진수 형태이다.
문제 A가 문제 B보다 먼저 출제되었고, A에서 사용하는 알고리즘이 B에서 사용하는 알고리즘을 모두 포함한다면 B를 웰논이라고 하고, 그렇지 않으면 애드혹이라 정의한다.
문제 A의 직전 문제가 웰논이었다면,
문제 A의 이진수에서 i번째 비트가 1인 경우에 i번 알고리즘을 사용한다는 의미이다.
직전 문제가 애드혹이었다면,
문제 A의 이진수에서 i번째 비트가 1인 경우에 (K-j+1)번 알고리즘을 사용한다는 의미이다.
🔍 풀이 방법
exist[a] = 이진수 a가 웰논이면 true, 아니면 false라는 boolean 배열을 관리한다.문제가 주어질 때마다 exist를 갱신해 나간다. 어떤 이진수 a가 주어지면, a & b = b를 만족하는 모든 b들은 이후에 웰논이 된다.
갱신 한 번에는 최대 O(KlogK)이지만, 갱신 과정을 활성 비트를 하나씩 끄는 방식의 재귀 함수로 짜면 갱신 N번에도 amortized O(KlogK)이다.
-> 결국 그냥
Bitmask DP기본 형태가 된다.⏳ 회고
흠