2096. Team Builder

单点时限: 5.0 sec

内存限制: 256 MB

You are arranging a weird game for a team building exercise. In this game there are certain locations that people can stand at, and from each location there are paths that lead to other locations, but there are not necessarily paths that lead directly back. You have everything set up, but you need to know two important numbers. There might be some locations from which every other location can be reached. There might also be locations that can be reached from every other location. You need to know how many of each of these there are.


There are many test cases!Each cases takes N describle a N paths that describes the way the locations are currently connected, Each element of paths will be a String containing as many characters as there are elements in paths. The i-th element of paths (beginning with the 0-th element) will contain a ‘1’ (all quotes are for clarity only) in position j if there is a path that leads directly from i to j, and a ‘0’ if there is not a path that leads directly from i to j.

-paths will contain between 2 and 20 elements, inclusive.

-Each element of paths will contain only the characters ‘0’ and ‘1’.

-Each element of paths will contain as many characters as there are elements in paths.


output exactly an int that is the fewest number of paths that must be added.


There are paths leaading from location 0 to location 1, and from location 1 to location 0. By adding a path from location 2 to itself, all locations will be able to follow a set of paths that lead back to themselves.

2 人解决,6 人已尝试。

2 份提交通过,共有 16 份提交。

9.4 EMB 奖励。

创建: 11 年,10 月前.

修改: 2 年,5 月前.

最后提交: 4 年前.

来源: TC