![]() |
||||||||||
|
||||||||||
DecompositionTime Limit: 5000/5000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 526 Accepted Submission(s): 223 Special Judge Problem Description 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. Input 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$. Output 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!}}$ Sample Input
Sample Output
Source | ||||||||||
|