#K56597. Minimum Traffic Light State Changes
Minimum Traffic Light State Changes
Minimum Traffic Light State Changes
You are given several test cases. In each test case, there are N intersections. Each intersection is described by a binary string where each character represents the state of a traffic light ('0' for red and '1' for green). An intersection is considered good if at least one of its traffic lights is green; otherwise, it is bad.
To make a bad intersection good, you need to change the state of at least one traffic light from red to green (i.e. one change per bad intersection). Your task is to determine the minimum number of changes required for each test case so that all intersections become good.
Formally, for each intersection represented by a binary string \(s\), if \(s\) does not contain the character '1', then it contributes \(1\) to the answer; otherwise, it contributes \(0\).
inputFormat
The input begins with an integer \(T\) (\(1 \leq T \leq 100\)), the number of test cases. For each test case:
- The first line contains an integer \(N\) (\(1 \leq N \leq 1000\)), representing the number of intersections.
- The following \(N\) lines each contain a binary string representing the traffic light state of an intersection.
outputFormat
For each test case, output a single integer on a new line representing the minimum number of changes required to turn all intersections into a good state.
## sample2
3
0101
0000
1110
2
000
101
1
1
</p>