Logo
(追記) (追記ここまで)

31055번 - A Graph Problem 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB93564862.338%

문제

To improve her mathematical knowledge, Bessie has been taking a graph theory course and finds herself stumped by the following problem. Please help her!

You are given a connected, undirected graph with vertices labeled 1ドル\dots N$ and edges labeled 1ドル\dots M$ (2ドル\le N\le 2\cdot 10^5,ドル $N-1\le M\le 4\cdot 10^5$). For each vertex $v$ in the graph, the following process is conducted: ​

  1. Let $S=\{v\}$ and $h=0$.
  2. While $|S|<N,ドル ​
    1. Out of all edges with exactly one endpoint in $S,ドル let $e$ be the edge with the minimum label.
    2. Add the endpoint of $e$ not in $S$ to $S$.
    3. Set $h=10h+e$.
  3. Return $h\pmod{10^9+7}$.

​ Determine all the return values of this process.

입력

The first line contains $N$ and $M$. ​ Then follow $M$ lines, the $e$th containing the endpoints $(a_e,b_e)$ of the $e$th edge (1ドル\le a_e<b_e\le N$). It is guaranteed that these edges form a connected graph, and at most one edge connects each pair of vertices.

출력

Output $N$ lines, where the $i$th line should contain the return value of the process starting at vertex $i$.

제한

예제 입력 1

3 2
1 2
2 3

예제 출력 1

12
12
21

예제 입력 2

5 6
1 2
3 4
2 4
2 3
2 5
1 5

예제 출력 2

1325
1325
2315
2315
5132

Consider starting at $i=3$. First, we choose edge 2ドル,ドル after which $S = \{3, 4\}$ and $h = 2$. Second, we choose edge 3ドル,ドル after which $S = \{2, 3, 4\}$ and $h = 23$. Third, we choose edge 1ドル,ドル after which $S = \{1, 2, 3, 4\}$ and $h = 231$. Finally, we choose edge 5ドル,ドル after which $S = \{1, 2, 3, 4, 5\}$ and $h = 2315$. The answer for $i=3$ is therefore 2315ドル$.

예제 입력 3

15 14
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15

예제 출력 3

678925929
678925929
678862929
678787329
678709839
678632097
178554320
218476543
321398766
431520989
542453212
653475435
764507558
875540761
986574081

Make sure to output the answers modulo 10ドル^9+7$.

힌트

출처

Olympiad > USA Computing Olympiad > 2023-2024 Season > USACO 2023 December Contest > Platinum 2번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /