[20250615] BOJ / D4 / XOR MST / 권혁준 #359
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/16901
🧭 풀이 시간
160분
👀 체감 난이도
✏️ 문제 설명
정점이 N개인 완전 그래프에서 각 간선의 가중치가 A[i] xor A[j]이다.
이 그래프의 MST 구하기.
🔍 풀이 방법
[사용한 알고리즘]
두 개의 트라이 P, Q를 둔다.
P에는 MST에 속해있는 점들의 A값이 들어가고, Q에는 MST에 아직 속하지 않은 점들의 A값이 들어가도록 한다.
초기에, P에는 1번 점만 넣고 Q에는 나머지 모든 점들을 넣는다.
그런 다음, Prim 알고리즘의 느낌대로 최소 xor 찾는 작업을 N-1번 반복하면 된다.
⏳ 회고
두 트라이에서의 최소 xor 찾기가 너무 어려웠다.