CF976F.Minimal k-covering

省选/NOI-

通过率:0%

时间限制:1.50s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a bipartite graph G = (U, V, E), U is the set of vertices of the first part, V is the set of vertices of the second part and E is the set of edges. There might be multiple edges.

Let's call some subset of its edges k-covering iff the graph has each of its vertices incident to at least k edges. Minimal k-covering is such a k-covering that the size of the subset is minimal possible.

Your task is to find minimal k-covering for each , where minDegree is the minimal degree of any vertex in graph G.

给你一个二分图 $ G = (U, V, E) $,其中 $ U $ 是第一部分的顶点集,$ V $ 是第二部分的顶点集,$ E $ 是边集。图中可能存在重边。

我们称其某一边子集 $ \tilde{E} \subseteq E $ 为 **$ k −覆盖∗∗(-覆盖**( k $-covering),当且仅当子图 $ \tilde{G} = (U, V, \tilde{E}) $ 中每个顶点的度数均至少为 $ k $。最小 $ k $-覆盖(minimal $ k $-covering)是指满足 $ k $-覆盖条件且边子集 $ \tilde{E} $ 的大小尽可能小的覆盖。

你的任务是:对每个 $ k = 1, 2, \dots, \text{minDegree} $,求出对应的最小 $ k $-覆盖,其中 $ \text{minDegree} $ 表示图 $ G $ 中任意顶点的最小度数。

输入格式

The first line contains three integers _n_1, _n_2 and m (1 ≤ _n_1, _n_2 ≤ 2000, 0 ≤ m ≤ 2000) — the number of vertices in the first part, the number of vertices in the second part and the number of edges, respectively.

The i-th of the next m lines contain two integers u__i and v__i (1 ≤ u__i ≤ _n_1, 1 ≤ v__i ≤ _n_2) — the description of the i-th edge, u__i is the index of the vertex in the first part and v__i is the index of the vertex in the second part.

第一行包含三个整数 n1n_1、n2n_2 和 mm(1≤n1,n2≤20001 \leq n_1, n_2 \leq 2000,0≤m≤20000 \leq m \leq 2000),分别表示二分图第一部分的顶点数、第二部分的顶点数以及边的数量。

接下来的 mm 行中,第 ii 行包含两个整数 uiu_i 和 viv_i(1≤ui≤n11 \leq u_i \leq n_1,1≤vi≤n21 \leq v_i \leq n_2),描述第 ii 条边:uiu_i 是第一部分中顶点的编号,viv_i 是第二部分中顶点的编号。

输出格式

For each print the subset of edges (minimal k-covering) in separate line.

The first integer cnt__k of the k-th line is the number of edges in minimal k-covering of the graph. Then cnt__k integers follow — original indices of the edges which belong to the minimal k-covering, these indices should be pairwise distinct. Edges are numbered 1 through m in order they are given in the input.

对于每个 kk,在单独一行中输出边的子集(最小 kk-覆盖)。

第 kk 行的第一个整数 cntk\text{cnt}_k 表示图的最小 kk-覆盖中所含边的数量。随后是 cntk\text{cnt}_k 个整数——属于最小 kk-覆盖的边的原始索引,这些索引应两两互异。边按输入顺序编号为 11 至 mm。

输入输出样例

  • 输入#1

    3 3 7
    1 2
    2 3
    1 3
    3 2
    3 3
    2 1
    2 1

    输出#1

    0 
    3 3 7 4 
    6 1 3 6 7 4 5
  • 输入#2

    1 1 5
    1 1
    1 1
    1 1
    1 1
    1 1

    输出#2

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

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

首页