아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Dance Mooves

시간 제한2초메모리 제한512 MB

요약
K개의 교환으로 이루어진 주기를 M분 동안 반복할 때 각 소가 서로 다른 몇 개의 위치를 거치는지 센다.
난이도

보통10점 중 7점

유형
그래프, 유니온 파인드, 시뮬레이션, 해시맵
정답자
아직 제출이 없습니다

문제

Farmer John’s cows are showing off their new dance mooves!

At first, all NN cows (2≤N≤1052\le N\le 10^5) stand in a line with cow ii in the iith position in line. The sequence of dance mooves is given by KK (1≤K≤2⋅1051\le K\le 2\cdot 10^5) pairs of positions (a_1,b_1),(a_2,b_2),…,(a_K,b_K)(a\_1,b\_1), (a\_2,b\_2), \ldots, (a\_{K},b\_{K}). In each minute i=1…Ki = 1 \ldots K of the dance, the cows in positions a_ia\_i and b_ib\_i in line swap. The same KK swaps happen again in minutes K+1…2KK+1 \ldots 2K, again in minutes 2K+1…3K2K+1 \ldots 3K, and so on, continuing in a cyclic fashion for a total of MM minutes (1≤M≤10181\le M\le 10^{18}). In other words,

  • In minute 11, the cows at positions a_1a\_1 and b_1b\_1 swap.
  • In minute 22, the cows at positions a_2a\_2 and b_2b\_2 swap.
  • ...
  • In minute KK, the cows in positions a_Ka\_{K} and b_Kb\_{K} swap.
  • In minute K+1K+1, the cows in positions a_1a\_{1} and b_1b\_{1} swap.
  • In minute K+2K+2, the cows in positions a_2a\_{2} and b_2b\_{2} swap.
  • and so on ...

For each cow, please determine the number of unique positions in the line she will ever occupy.

입력

The first line contains integers NN, KK, and MM. Each of the next KK lines contains (a_1,b_1)…(a_K,b_K)(a\_1,b\_1) \ldots (a\_K, b\_K) (1≤a_i\<b_i≤N1\le a\_i\<b\_i\le N).

출력

Print NN lines of output, where the iith line contains the number of unique positions that cow ii reaches.

예제

이 문제는 공개된 예제가 없습니다.