#P14450. [ICPC 2025 Xi'an R] Directed Acyclic Graph

    ID: 14394 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>图论2025Special Judge构造ICPC西安

[ICPC 2025 Xi'an R] Directed Acyclic Graph

题目描述

Given two integers nn and mm, you need to construct a directed acyclic graph (DAG) G=(V,E)G = (V, E) with exactly nn vertices and mm edges.

In the graph GG, a vertex vv is called reachable\textit{reachable} from vertex uu if and only if there exists a path in the graph that starts at vertex uu and ends at vertex vv.

For a non-empty set of vertices AVA\subseteq V, a vertex ww is defined as good\textit{good} for AA if and only if it is reachable from every\textbf{every} vertex in AA, and we denote f(A)f(A) as the set of all good vertices for AA.

The graph you constructed should satisfy both of the following constraints:

  • For every vertex ii (1in1\le i\le n), it is reachable from vertex 11.
  • There exist kk distinct non-empty sets of vertices S1,S2,,SkS_1, S_2, \ldots, S_k, such that f(S1),f(S2),,f(Sk)f(S_1), f(S_2), \ldots, f(S_k) are pairwise distinct. Note that f(Si)f(S_i) can be empty.

To prove the graph GG you constructed satisfies the second constraint, you also need to provide kk sets S1,S2,,SkS_1, S_2,\ldots, S_k that satisfy the second constraint.

输入格式

The only line of the input contains three integers n,mn, m, and kk.

There are only 22 tests in this problem:

  • n=5n = 5, m=6m = 6, k=6k = 6;
  • n=100n = 100, m=128m = 128, k=16000k = 16\,000.

输出格式

The first mm lines of the output describe the graph GG you construct. Each line contains two integers u,vu, v representing an edge from uu to vv in the graph.

The next kk lines of the output describe the kk sets of vertices you provide. The ii-th line first contains the size of the set SiS_i, followed by the Si|S_i| numbers representing each vertex in the set.

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

提示

In the example, the output constructs a graph with n=5n = 5 vertices and m=6m = 6 edges. The corresponding k=6k = 6 sets are $S_1 = \{1\}, S_2 = \{2\}, S_3 = \{3\}, S_4 = \{4\}, S_5 = \{5\}, S_6 = \{2, 3\}$.

Here, vertices 44 and 55 can both be reached from any element in S6={2,3}S_6 = \{2, 3\}, so f({2,3})={4,5}f(\{2, 3\}) = \{4, 5\}. Together with $f(S_1) = \{1, 2, 3, 4, 5\}, f(S_2) = \{2, 4, 5\}, f(S_3) = \{3, 4, 5\}, f(S_4) = \{4\}, f(S_5) = \{5\}$, these sets are all distinct, satisfying the constraints.

:::align{center} :::