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

21228번 - Counting Graphs 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB297518.519%

문제

Bessie has a connected, undirected graph $G$ with $N$ vertices labeled 1ドル\ldots N$ and $M$ edges (2ドル\le N\le 10^2, N-1\le M\le \frac{N^2+N}{2}$). $G$ may contain self-loops (edges from nodes back to themselves), but no parallel edges (multiple edges connecting the same endpoints).

Let $f_G(a,b)$ be a boolean function that evaluates to true if there exists a path from vertex 1ドル$ to vertex $a$ that traverses exactly $b$ edges for each 1ドル\le a\le N$ and 0ドル\le b,ドル and false otherwise. If an edge is traversed multiple times, it is included that many times in the count.

Elsie wants to copy Bessie. In particular, she wants to construct an undirected graph $G'$ such that $f_{G'}(a,b)=f_G(a,b)$ for all $a$ and $b$.

Your job is to count the number of distinct graphs $G'$ that Elsie may create, modulo 10ドル^9+7$. As with $G,ドル $G'$ may contain self-loops but no parallel edges (meaning that there are 2ドル^{\frac{N^2+N}{2}}$ distinct graphs on $N$ labeled vertices in total).

Each input contains $T$ (1ドル\le T\le \frac{10^5}{4}$) test cases that should be solved independently. It is guaranteed that the sum of $N^2$ over all test cases does not exceed 10ドル^5$.

입력

The first line of the input contains $T,ドル the number of test cases.

The first line of each test case contains the integers $N$ and $M$.

The next $M$ lines of each test case each contain two integers $x$ and $y$ (1ドル\le x\le y\le N$), denoting that there exists an edge between $x$ and $y$ in $G$.

Consecutive test cases are separated by newlines for readability.

출력

For each test case, the number of distinct $G'$ modulo 10ドル^9+7$ on a new line.

제한

예제 입력 1

1
5 4
1 2
2 3
1 4
3 5

예제 출력 1

3

In the first test case, $G'$ could equal $G$ or one of the two following graphs:

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

예제 입력 2

7
4 6
1 2
2 3
3 4
1 3
2 4
1 4
5 5
1 2
2 3
3 4
4 5
1 5
5 7
1 2
1 3
1 5
2 4
3 3
3 4
4 5
6 6
1 2
2 3
3 4
4 5
5 6
6 6
6 7
1 2
2 3
1 3
1 4
4 5
5 6
1 6
10 10
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
22 28
1 2
2 3
3 4
4 5
5 6
6 7
1 7
1 8
3 9
8 10
10 11
10 12
10 13
10 14
11 15
12 16
13 17
14 18
9 15
9 16
9 17
9 18
15 19
19 20
15 20
16 21
21 22
16 22

예제 출력 2

45
35
11
1
15
371842544
256838540

These are some larger test cases. Make sure to output the answer modulo 10ドル^9+7$. Note that the answer for the second-to-last test case is 2ドル^{45}\pmod{10^9+7}$.

힌트

출처

Olympiad > USA Computing Olympiad > 2020-2021 Season > USACO 2021 February Contest > Platinum 3번

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

출처

대학교 대회

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

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