Pro.ID21641 TitleBored S Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21641 AC0 Submit0 Ratio- 时间&空间限制描述One day, S was so bored that he did something boring like this. He drew N points on the paper, and added a loop, that is, an edge connecting a point and itself, on each point. Then, he added several edges between different points, randomly. It's guaranteed that there was no more than one edge between a pair of points. So, there he gained an undirected graph G without any parallel edge. Finally, he figured out the adjacent matrix A of the graph G, and calculated A2. Here you're given only the finally matrix A2, S wants to know whether there is a way to travel all the edges on graph G once and exactly once, and end at the point where the journey starts. Could you answer him? 输入The first line is an integer T ( T ≤ 20 ), indicating the number of test cases. Each case is in the format like this: First line is a positive integer N ( N ≤ 100 ), indicating the number of points of the graph. Then there are N lines following, with N space-separated integers on each line. The j-th integer on the i-th line is the (i, j) element of matrix A2. 输出Description One day, S was so bored that he did something boring like this. He drew N points on the paper, and added a loop, that is, an edge connecting a point and itself, on each point. Then, he added several edges between different points, randomly. It's guaranteed that there was no more than one edge between a pair of points. So, there he gained an undirected graph G without any parallel edge. Finally, he figured out the adjacent matrix A of the graph G, and calculated A2. Here you're given only the finally matrix A2, S wants to know whether there is a way to travel all the edges on graph G once and exactly once, and end at the point where the journey starts. Could you answer him? Input The first line is an integer T ( T ≤ 20 ), indicating the number of test cases. Each case is in the format like this: First line is a positive integer N ( N ≤ 100 ), indicating the number of points of the graph. Then there are N lines following, with N space-separated integers on each line. The j-th integer on the i-th line is the (i, j) element of matrix A2. Output For each test case, print one line with the string "Yes" or "No" (quotes for clarity), according to your answer to the question above. Sample Input 2 Sample Output Yes Hint B = A2 if and only if ( A is an n*n matrix and the elements are 0-based ) Source 样例输入2 样例输出Yes 提示B = A2 if and only if ( A is an n*n matrix and the elements are 0-based ) |