[BOJ 16182] Dumae
https://www.acmicpc.net/problem/16182 16182번: Dumae The first line contains two space-separated integers $N, M$. ($1 \leq N \leq 300,000,\ 0 \leq M \leq 1,000,000$) In the next $N$ lines, two space-separated integers $L_i,\ R_i$ are given. ($1 \leq L_i \leq R_i \leq N$) In the next $M$ lines, two space-sepa www.acmicpc.net Tag : Topological Sort, Greedy, Path Compression 문제 요약 위상정렬 순서에 어긋나지 않게 자..
[BOJ 2682] 최대 사이클 1
https://www.acmicpc.net/problem/2682 2682번: 최대 사이클 1 P는 1부터 n까지 수로 이루어진 순열이다. 최대 사이클 1은 P(1), P(P(1)), P(P(P(1))), ... 중 최댓값이다. 예를 들어 수열 P가 (3, 2, 5, 4, 1, 7, 8, 6) 이라면 P(1) = 3 P(P(1)) = P(3) = 5 P(P(P(1))) = P(5) = 1 따라서 3, 5, www.acmicpc.net Tag : Combinatorics 풀이 순열 \(P\)는 \( 1 N >> K; ll ans = 0; for(ll sz = 2; sz