#P13181. [GCJ 2017 Finals] Spanning Planning
[GCJ 2017 Finals] Spanning Planning
题目描述
A spanning tree of an undirected graph with nodes is a tree with edges that uses only edges from and includes all nodes in .
Please construct a graph with at least nodes, and no more than nodes, such that the graph has exactly different spanning trees. (Two spanning trees are considered different if and only if the sets of edges that they use are different.) The graph must have at most one edge per pair of nodes, and must not contain a loop (an edge from a node to itself).
It is guaranteed that at least one such graph exists for every within the limits below.
输入格式
The first line of the input gives the number of test cases, . test cases follow. Each consists of one line with an integer : the desired number of spanning trees.
输出格式
For each test case, first output one line containing Case #x: y
, where is the test case number (starting from 1), and is the number of nodes in your graph. ( must be between 2 and 22, inclusive.) Then, output more lines. The -th of these lines represents the -th node in the graph, and must contain exactly characters. The -th character on the -th line should be 1 if the -th node and the -th node are connected with an edge, and 0 otherwise. Note that this matrix will be symmetric and it will have all 0s along its main diagonal.
If multiple answers are possible, you may output any of them. Note that we guarantee that at least one valid answer exists for every within the limits below.
2
3
8
Case #1: 3
011
101
110
Case #2: 4
0111
1001
1001
1110
提示
Sample Explanation
In Case #1, the graph is a triangle, and removing any one edge creates a different spanning tree.
In Case #2, the available edges in our solution tree are , , , , and . The eight different spanning trees are defined by these sets of edges:
- , ,
- , ,
- , ,
- , ,
- , ,
- , ,
- , ,
- , ,
Limits
- .
Small dataset (30 Pts, Test Set 1 - Visible)
- .