QOJ.ac

QOJ

حد الوقت: 3 s حد الذاكرة: 256 MB مجموع النقاط: 100

#12202. 璀璨星辰

الإحصائيات

Rabbit 喜欢观察星星。她观察了 $N$ 颗星星,并打算记录其中的一些。

有些星星对是相似的,而另一些则不是。相似关系是对称的,即星星对 $\{A, B\}$ 与 $\{B, A\}$ 被视为相同。此外,满足以下条件:如果有四颗不同的星星 $A, B, C$ 和 $D$,使得 $\{A, B\}$、$\{B, C\}$ 和 $\{C, D\}$ 相似,那么 $\{A, C\}$ 或 $\{B, D\}$(或两者)也是相似的。

Rabbit 希望尽可能多地记录星星,但她绝不会在笔记本上记录两颗相似的星星。请编写一个程序,求出她能记录的星星的最大数量,以及有多少种星星的组合可以达到这个最大数量,结果对 $1\,000\,000\,007$ 取模。

输入格式

输入格式如下:

$N \ M$ $X_1 \ Y_1$ $\vdots$ $X_M \ Y_M$

第一行包含两个整数 $N$ 和 $M$ ($1 \le N \le 100\,000, 0 \le M \le 200\,000$),其中 $N$ 是星星的数量,$M$ 是相似对的数量。接下来的 $M$ 行中,第 $i$ 行 ($1 \le i \le M$) 包含两个整数 $X_i$ 和 $Y_i$ ($1 \le X_i < Y_i \le N$),表示第 $X_i$ 颗星星和第 $Y_i$ 颗星星相似。$M$ 个相似对 $\{X_i, Y_i\}$ 各不相同。相似关系满足题目描述中的条件。

输出格式

程序应输出两行。第一行包含她能记录的星星的最大数量。第二行包含能达到该最大数量的星星组合数,对 $1\,000\,000\,007$ 取模。

样例

样例输入 1

4 3
1 2
1 3
1 4

样例输出 1

3
1

样例输入 2

11 5
1 2
3 4
5 6
7 8
9 10

样例输出 2

6
32

样例输入 3

9 14
1 2
1 3
2 3
3 4
3 5
3 6
3 7
3 8
3 9
4 5
4 6
5 6
7 8
8 9

样例输出 3

4
6

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.