F. Information Transmission-1

    传统题 1000ms 128MiB

Information Transmission-1

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

Problem Description

Information resources are information producers, information and information technology organisms. The fundamental purpose of information management is to control the flow of information and realize the utility and value of information. The broad meaning of information transmission is the transfer of information between media. Strictly speaking, all information processing is the transfer of information within the organization, that is, the movement of information in its physical location.



Information transmission methods include one-way transmission, two-way transmission, half-two-way transmission (only one direction per transmission), multi-channel transmission (one channel through multiple signals), etc.



Now, a university has a urgent notice, hoping all teachers can see the content at the first time. The physical location of all teachers is known , Once a teacher (xi,yi ) receives information,  he or she immediately passes it to another teacher in the adjacent position (xi+1,yi ) or (xi-1,yi ) or (xi,yi+1 ) or (xi,yi -1).



You can tell the authority , at first which teachers should be notified at least to ensure that everyone can see the notice content at the first time.

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:    m  n                  ( 1 ≤ m ≤ 200, 1 ≤ n ≤ 500  )

* Line 2~m+1:  Each row has n numbers, ‘1’ indicates that there is a teacher in this position.

Output Format

For each test case generate a single line:  minimum number of teachers to be notified first.

2
1 10
1110111111
7 9
000110000
110010001
010011011
000000000
111111100
010100100
111111100
5
17

Source

2019河南省赛

2019河南省ACM省赛重现-Copy

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