0
点赞
收藏
分享

微信扫一扫

No.18 Is It a Tree

小沙坨 2022-02-20 阅读 52
c++c语言

原文:

Is It a Tree 

1000ms 65536kB

描述:

输入:

First line: one positive integers N (N <= 100).
Next N lines: an N*N 0/1 matrix A={a[i][j]}, indicating whether there exists an edge between node i and node j (a[i][j]=1) or not (a[i][j]=0).

输出:

One integer, 1 if the graph is a tree, or 0 otherwise.

样例输入:

4
0 1 0 1
1 0 1 0
0 1 0 0
1 0 0 0

样例输出:

1

参考译文:

这是一棵树吗?

描述:

输入:

第一行包含一个整数N

接下来N行,用于表示一个N*N的矩阵,用0表示该处没有节点,用1表示该处有节点

输出:

一个整数,1表示该图是一棵树,否则输出0。

样例输入:

4
0 1 0 1
1 0 1 0
0 1 0 0
1 0 0 0

样例输出:

1
举报

相关推荐

0 条评论