#609. 「Nowcoder多校 2019 Day6」Androgynos

「Nowcoder多校 2019 Day6」Androgynos

当前没有测试数据。

题目描述

In graph theory, an isomorphism of graphs G and H is a bijection between the vertex sets of G and H. The complement of a graph G is a graph H on the same vertices such that two distinct vertices of H are adjacent if and only if they are not adjacent in G. Give a positive integer n, check whether there exists a simple undirected graph G having n vertices, which is isomorphic to its complement graph H. If the graphs G and H exist, report them with any possible isomorphism.

输入格式

There are multiple test cases. The first line contains an integer T (1T51 \leq T \leq 5), indicating the number of test cases. Test cases are given in the following.Each test case consists of only one line, containing an integer n (1n20001 \leq n \leq 2000).

输出格式

For each test case, output "Case #x: y" in one line (without quotes), where x indicates the case number starting from 1, and y (y{Yes,No}y \in \lbrace \text{Yes}, \text{No} \rbrace) denotes whether or not the graphs exist in this test case. If the graphs exist, then output (n + 1) extra lines.The first n lines represent the graph G, where each line contains a binary string of length n. In the i-th line, the j-th character Gi,jG_{i, j}​ is '1' when the i-th vertex and the j-th one are adjacent, or otherwise, in case they are not adjacent, Gi,jG_{i, j}​ is '0'. Note that Gi,iG_{i, i}​ must be '0' and Gi,jG_{i, j}​ must be the same as Gj,iG_{j, i} The last line contains n space-separated integers f1f_1, f2f_2​, ……, fnf_n, representing an isomorphism of graphs G and H in which the i-th vertex in the graph G is mapped to the fif_i-th vertex in the complement graph H. Note that every two consecutive integers in one line should be separated by a single space, please do not add any tailing space in your output\text{please do not add any tailing space in your output}please do not add any tailing space in your output.

样例

样例输入 1

4
1
2
3
4

样例输出 1

Case #1: Yes
0
1
Case #2: No
Case #3: No
Case #4: Yes
0100
1010
0101
0010
2 4 1 3