CF1701A.Grass Field

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a field of size 2×22 \times 2 . Each cell of this field can either contain grass or be empty. The value ai,ja_{i, j} is 11 if the cell (i,j)(i, j) contains grass, or 00 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 xx and the column yy , then you cut the grass in all cells ax,ia_{x, i} and all cells ai,ya_{i, y} for all ii from 11 to 22 . After you cut the grass from a cell, it becomes empty (i. e. its value is replaced by 00 ).

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,ja_{i, j} zeros).

You have to answer tt independent test cases.

输入格式

The first line of the input contains one integer tt ( 1t161 \le t \le 16 ) — the number of test cases. Then tt test cases follow.

The test case consists of two lines, each of these lines contains two integers. The jj -th integer in the ii -th row is ai,ja_{i, j} . If ai,j=0a_{i, j} = 0 then the cell (i,j)(i, j) is empty, and if ai,j=1a_{i, j} = 1 the cell (i,j)(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,ja_{i, 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
首页