[20251217] BOJ / D3 / Vjeverice / 권혁준#1700
Merged
ShinHeeEul merged 1 commit intomainfrom Dec 17, 2025
Merged
Conversation
Contributor
Author
x = par[x][0];
root[x] = find(par[x][0]);-> union과 부모 이동의 순서가 잘못됨. if(a != b) {
mx = Math.max(Math.max(max[a][0], max[b][0]);
}-> max값 갱신이 잘못됨. |
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/28713
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
정점 N개, 간선 M개인 그래프가 주어지고, 특정 간선의 가중치가 바뀌는 시나리오가 Q번 주어지면, 각 시나리오에서의 MST 가중치 합을 구해보자.
🔍 풀이 방법
일단 MST를 구해놓고, 시나리오에서 처리하는 간선이 MST에 사용된 간선인 경우와 그렇지 않은 경우로 나눈다.
만약 MST에 사용된 간선인 경우에는 그 간선을 뺐을 때 분리되는 두 컴포넌트를 잇는 최소 가중치의 간선을 찾아서 끼워넣으면 된다. 혹은 바뀐 가중치가 더 작다면 그걸 넣으면 된다.
대체 간선은 분리 집합 + LCA로 전처리 가능하다.
MST에 사용되지 않은 간선인 경우에는 그 간선이 MST상에서 이루는 경로 상의 최대 가중치를 찾아서 빼주거나, 기존의 MST를 그대로 사용하면 된다.
희소 배열로 경로 최대 가중치를 구할 수 있다.
⏳ 회고
근데 왜 틀리지?