Occupy the Cities
시간 제한1초메모리 제한1024 MB
길이 n의 이진 문자열이 주어지고, 매 라운드마다 점령된 도시가 인접한 비점령 도시 하나를 공격 대상으로 표시하면 그 도시들이 점령된다. 모든 도시를 점령하는 최소 라운드 수를 구한다.
문제
JB is playing a game. There are cities in the game, numbered as . The -th city and the -th city are adjacent if and only if or . Initially, some of the cities are occupied by JB.
The game runs in rounds. At the beginning of a round, each occupied city can mark at most one adjacent unoccupied city as the target of attack. At the end of the round, all the attack targets marked become occupied. The game ends when all the cities are occupied.
JB wants to occupy all the cities in minimum rounds. Can you help him?
입력
There are multiple test cases. The first line of the test case contains a positive integer , indicating the number of test cases. For each test case:
The first line contains an integer (), indicating the number of cities.
The next line contains a string of length . It's guaranteed only contains '0' and '1'. The -th character describes the initial state of the -th city: if '1', the -th city is occupied by JB initially. Otherwise, the -th city is not occupied initially.
It's guaranteed that the sum of over all the test cases doesn't exceed . It's also guaranteed that there is at least one '1' in .
출력
For each test case, output one line, containing the minimum number of rounds to occupy all the cities.
힌트
For the second test case, the best way is .