RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0589

A Graph Problem

Diamond V 다이아몬드 V
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

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|, Out of all edges with exactly one endpoint in \(S\), let \(e\) be the edge with the minimum label.
  3. Add the endpoint of \(e\) not in \(S\) to \(S\).
  4. Set \(h=10h+e\).

Return \(h\pmod{10^9+7}\).

Determine all the return values of this process.

Problem credits: Benjamin Qi

제약

SCORING

  • Input 4: \(N,M\le 2000\)
  • Inputs 5-6: \(N\le 2000\)
  • Inputs 7-10: \(N\le 10000\)
  • Inputs 11-14: \(a_e+1=b_e\) for all \(e\)
  • Inputs 15-23: No additional constraints.

Problem credits: Benjamin Qi

입력 형식

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). 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
출력
12
12
21
예제 2
입력
5 6
1 2
3 4
2 4
2 3
2 5
1 5
출력
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
출력
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\).

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2023-2024 > December > Platinum

태그

평가 및 의견

A Graph Problem

개요
출제자 난이도 Diamond V 다이아몬드 V 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

A Graph Problem

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8