Skip to content

Conversation

@oncsr
Copy link
Contributor

@oncsr oncsr commented Oct 10, 2025

🧷 문제 링크

https://www.acmicpc.net/problem/15370

🧭 풀이 시간

20분

👀 체감 난이도

✏️ 문제 설명

간선 없는 정점 N개인 그래프와, 정수 M이 주어진다.
i번째 날에는 gcd(a,b) = M-i+1인 정점 a와 b 사이를 잇는 간선이 생긴다.

Q개의 쿼리를 처리해보자.

  • A B : A와 B가 이어지는 최소 일차?

🔍 풀이 방법

  • 분리 집합
  • 희소 배열

harmonic lemma 때문에 간선을 직접 만들어도 O(MlogM)임.

  1. 분리 집합으로 이어주기
  2. 만들어진 트리에서 max sparse table 생성 -> 쿼리 처리는 경로의 max값으로

⏳ 회고

왜이렇게 높지

@oncsr oncsr added the success 👍 해설을 보지 않고 풀었을 때 label Oct 10, 2025
@ShinHeeEul ShinHeeEul merged commit e829eb4 into main Oct 10, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

success 👍 해설을 보지 않고 풀었을 때

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants