CF1701A.Grass Field
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is a field of size 2×2 . Each cell of this field can either contain grass or be empty. The value ai,j is 1 if the cell (i,j) contains grass, or 0 otherwise.
In one move, you can choose one row and one column and cut all the grass in this row and this column. In other words, you choose the row x and the column y , then you cut the grass in all cells ax,i and all cells ai,y for all i from 1 to 2 . After you cut the grass from a cell, it becomes empty (i. e. its value is replaced by 0 ).
Your task is to find the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all ai,j zeros).
You have to answer t independent test cases.
输入格式
The first line of the input contains one integer t ( 1≤t≤16 ) — the number of test cases. Then t test cases follow.
The test case consists of two lines, each of these lines contains two integers. The j -th integer in the i -th row is ai,j . If ai,j=0 then the cell (i,j) is empty, and if ai,j=1 the cell (i,j) contains grass.
输出格式
For each test case, print one integer — the minimum number of moves required to cut the grass in all non-empty cells of the field (i. e. make all ai,j zeros) in the corresponding test case.
输入输出样例
输入#1
3 0 0 0 0 1 0 0 1 1 1 1 1
输出#1
0 1 2