当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7028:Decomposition

Special Judge 特殊评判
题目描述
You are given an undirected complete graph with $n$ vertices ($n$ is odd). You need to partition its edge set into $k$ $\pmb{\text{disjoint simple}}$ paths, satisfying that the $i$-th simple path has length $l_i$ ($1\leq i \leq k, 1 \leq l_i \leq n-3$), and each undirected edge is used exactly once.

A complete graph is a simple undirected graph in which every pair of distinct vertices is connected by a unique edge. A simple path with length $l$ here means the path covers $l$ edges, and the vertices in the path are pairwise distinct.

It can be proved that an answer always exists if $\sum\limits_{i=1}^k l_i = \frac{n(n-1)}{2}$ holds.
输入解释
The first line contains an integer $T(1 \leq T \leq 100000)$ - the number of test cases. Then $T$ test cases follow.

The first line of each test case contains two integers $n, k(5 \leq n \leq 1000, 1 \leq k \leq \frac{n(n-1)}{2}, n \equiv 1 \pmod 2)$ - the number of vertices and paths.

The next line contains $k$ integers $l_1, l_2, \cdots, l_k(1 \le l_i \le n-3)$ - the length of each path.

It is guaranteed that $\sum\limits_{i=1}^k l_i = \frac{n(n-1)}{2}$ holds for each test case, and $\sum \frac{n(n-1)}{2} \leq 4 \times 10^6$.
输出解释
For each test case, firstly output one line containing "Case #x:", where $x(1 \leq x \leq T)$ is the test case number. Then output $k$ lines. the $i$-th line contains $l_i + 1$ numbers denoting the $i$-th path.

If there are multiple answers, print any.

$\pmb{\text{Due to technical reasons, please, do not output extra spaces at the end of each line!}}$
输入样例
3
5 6
2 1 1 2 2 2
7 8
1 1 4 3 4 1 3 4
5 10
1 1 1 1 1 1 1 1 1 1
输出样例
Case #1:
5 4 2
2 3
5 1
2 1 4
3 5 2
1 3 4
Case #2:
6 7
1 3
6 5 1 2 3
7 1 4 2
1 6 4 7 5
7 3
2 6 3 5
3 4 5 2 7
Case #3:
5 3
5 2
4 3
1 5
1 3
2 3
4 2
4 1
1 2
4 5

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7028

最后修改于 2021-10-23T19:11:06+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000/5000MS(Java/Others) 524288/524288K(Java/Others)