G. Information Transmission-2

    传统题 1000ms 128MiB

Information Transmission-2

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Description

Information plays a very important role in people's social life. For example, scientific research must not only obtain the results of others 'research in time, but also publish and inform others of the results of their own research in time. Only through this exchange of information can we continue to develop. Network communication is based on computer communication network for information transmission, exchange and utilization.



There are n base points and there is a certain transfer relationship between them., the information can be transmitted from point A to point B, and point B to point C, and so on.  Now there is a massage to be broadcasted ,  at least which base points to be sent the message first, so that all the base points can be received?

Input Format

The first line of the input contains one integer T, which is the number of  test cases (1<=T<=8).  Each test case specify:

     * Line 1:      n           (2 ≤ n ≤ 100)

  *Line 2~n+1:  each line contains a 01 string of length n .

ie:if the sixth column in the third row is 1, it means that the third base point can pass the message to the sixth base point.

Output Format

For each test case generate a single line:  minimum number of base that the massage must be sent first, so that all the basis points can be received.

2
3
010
001
000
6
010000
001001
000100
010000
001000
000000
1 
2

Source

2019河南省赛

2019河南省ACM省赛重现-Copy

未参加
状态
已结束
规则
XCPC
题目
10
开始于
2021-5-9 21:45
结束于
2021-5-10 2:45
持续时间
5 小时
主持人
参赛人数
11