A811.Counting Graphs--Platinum

NOI/NOI+/CTSC

USACO

通过率:0%

时间限制:1.00s

内存限制:128MB

题目描述

Bessie has a connected, undirected graph GG with NN vertices labeled
1…N1\ldots N and MM edges (2≤N≤102,N−1≤M≤N2+N22\le N\le 10^2, N-1\le M\le \frac{N^2+N}{2}). GG
may contain self-loops (edges from nodes back to themselves), but no parallel
edges (multiple edges connecting the same endpoints).
Let fG(a,b)f_G(a,b) be a boolean function that evaluates to true if there exists a
path from vertex 11 to vertex aa that traverses exactly bb edges for each
1≤a≤N1\le a\le N and 0≤b0\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′G' such that fG′(a,b)=fG(a,b)f_{G'}(a,b)=f_G(a,b) for all aa and bb.
Your job is to count the number of distinct graphs G′G' that Elsie may create,
modulo 109+710^9+7. As with GG, G′G' may contain self-loops but no parallel
edges (meaning that there are 2N2+N22^{\frac{N^2+N}{2}} distinct graphs on NN
labeled vertices in total).
Each input contains TT (1≤T≤10541\le T\le \frac{10^5}{4}) test cases that should be
solved independently. It is guaranteed that the sum of N2N^2 over all test
cases does not exceed 10510^5.

输入格式

The first line of the input contains TT, the number of test cases.
The first line of each test case contains the integers NN and MM.
The next MM lines of each test case each contain two integers xx and yy
(1≤x≤y≤N1\le x\le y\le N), denoting that there exists an edge between xx and yy
in GG.
Consecutive test cases are separated by newlines for readability.

输出格式

For each test case, the number of distinct G′G' modulo 109+710^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′G' could equal GG 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≤N≤1002\le N\le100,N−1≤M≤N2+N2N-1\le M\le\frac{N^2+N}{2},1≤T≤250001\le T\le25000,且所有测试用例的N2N^2之和不超过10510^5。

测试点编号 NN
3 2≤N≤52\le N\le5
4<>im20 2≤N≤1002\le N\le100

原题评分条件:测试点4\sim5中的所有测试用例满足M=N−1M=N-1。测试点6\sim11中,对任意一组顶点x,yx,y,若存在bb使fG(x,b)≠fG(y,b)f_G(x,b)\ne f_G(y,b),则存在bb使fG(x,b)f_G(x,b)为真且fG(y,b)f_G(y,b)为假。测试点12\sim20无额外限制。

输入解题思路,AI测评打分。不知道怎么写?

首页