#P11163. [OOI 2025] Strong Connectivity Strikes

[OOI 2025] Strong Connectivity Strikes

题目描述

Vertices uu and vv of a directed graph are called strongly connected if there exists a path from uu to vv and a path from vv to uu in the graph. Note that if uu and vv are strongly connected, and vv and ww are strongly connected, then uu and ww are also strongly connected. Therefore, the vertices of the graph are divided into sets---strongly connected components. A vertex belonging to a strongly connected component is strongly connected to all vertices in the component (including itself) and is not strongly connected to any vertices outside the component.

During a graph class, Alice drew a directed graph with nn vertices on the board and highlighted its strongly connected components. During the break, Bob decided to play a trick on Alice and erase the directions on some edges of the graph. He wants Alice to be able to uniquely restore the erased directions based on the remaining edges and the partition into strongly connected components after the break.

Help Bob by determining the maximum number of edges in the graph whose directions he can erase, as well as the number of ways he can do this.

More formally, find the maximum size of a subset of edges AA that has the following property: if the directions of the edges in the set AA are erased, then based on the information about the old strongly connected components and the directions of the edges not in the set AA, the directions of the edges in the set AA can be uniquely restored in such a way that the strongly connected components remain unchanged.

Since the number of such maximum subsets can be very large, output it modulo 109+710^9 + 7.

Solutions that correctly determine the maximum size of the set AA but incorrectly present the number of such subsets will receive partial points.

输入格式

The first line contains three integers nn, mm, and gg (2n20002 \le n \le 2000, 1m20001 \le m \le 2000, 0g70 \le g \le 7)---the number of vertices and edges in the graph, respectively, as well as the test group number.

The next mm lines contain two integers uiu_i and viv_i (1ui,vin1 \le u_i, v_i \le n, uiviu_i \neq v_i)---the numbers of the vertices that are the start and end of the ii-th edge.

It is guaranteed that for any 1i,jn1 \le i, j \le n (ui,vi)(uj,vj)(u_i, v_i) \neq (u_j, v_j) and (ui,vi)(vj,uj)(u_i, v_i) \neq (v_j, u_j), meaning that any two vertices are connected by at most one edge, regardless of direction.

输出格式

In the first line, output a single number---the size of the maximum subset of edges whose directions can be erased.

In the second line, output a single number---the number of such subsets modulo 109+710^9 + 7. If you do not want to present the number of such subsets, then in the second line, instead, output any number from 1-1 to 109+610^9 + 6. In this case, your solution will receive partial points for the test.

Note that omitting any number in the second line leads to a verdict of "Wrong Answer" and zero points for this test, regardless of the correctness of the size of the subset.

输入输出样例 #1

输入 #1

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

输出 #1

3
3

说明/提示

Note

The graph from the example with strongly connected components highlighted:

The directions on the dashed edges can be removed. Indeed, the edge (1,5)(1, 5) cannot be oriented in the opposite direction, because otherwise, vertices 11, 22, 33, and 55 would belong to the same strongly connected component. The edges (3,4)(3, 4) and (4,2)(4, 2) cannot be oriented differently either, because then vertices 22, 33, and 44 would not belong to the same strongly connected component.

Now, let's consider an incorrect way of selecting a subset of edges:

Here, the directions on the bold dashed edges cannot be removed. For example, if we reverse the orientation of edges (1,2)(1, 2) and (1,5)(1, 5), we get a graph with the same decomposition into strongly connected components.

It can be shown that the directions on exactly 44 edges cannot be removed, so the answer is 33.

Scoring

The tests for this problem consist of seven groups. The rules for scoring the subgroups are described below.

If the size of the maximum subset of edges whose directions can be erased and the number of such subsets are correctly calculated in all tests of the group, full points are awarded for the group.

Otherwise, if the size of the maximum subset of edges whose directions can be erased is correctly calculated in all tests of the group, but the number is incorrect in at least one test of the group, partial points are awarded for the group. Note that dependent groups will be tested in this case and may even be scored full points.

Group Partial Points Full Points Additional Constraints: nn Additional Constraints: mm Required Groups Comment
0 -- Examples.
1 7 11 n14n \le 14 m14m \le 14 0
2 5 9 n20n \le 20 m20m \le 20 0, 1
3 8 12 -- -- ui<viu_i < v_i, for all 1in11 \le i \le n - 1 there is an edge (i,i+1)(i, i + 1)
4 13 3 ui<viu_i < v_i
5 12 20 -- for all 1in11 \leqslant i \leqslant n - 1 there is an edge (i,i+1)(i, i + 1), there is an edge (n,1)(n, 1)
6 13 21 5 the graph consists of one strongly connected component
7 8 14 0 -- 6