A. Grass Field

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

There is a field of size 2×22×2. Each cell of this field can either contain grass or be empty. The value ai,jai,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,iax,i and all cells ai,yai,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,jai,j zeros).

You have to answer tt independent test cases.

Input

The first line of the input contains one integer tt (1≤t≤161≤t≤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,jai,j. If ai,j=0ai,j=0 then the cell (i,j)(i,j) is empty, and if ai,j=1ai,j=1 the cell (i,j)(i,j) contains grass.

Output

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,jai,j zeros) in the corresponding test case.

Example

input

Copy

 

3

0 0

0 0

1 0

0 1

1 1

1 1

output

Copy

0
1
2

解题说明:此题是一道模拟题,每次可以选择一行+一列进行清除,找规律能发现就是把4个数加起来除以2。注意四个数加起来为1的时候要单独考虑。

#include <stdio.h>

int main()
{
	int n, a, b, c, d, i;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d%d", &a, &b);
		scanf("%d%d", &c, &d);
		if (a + b + c + d == 1)
		{
			printf("1\n");
		}
		else
		{
			printf("%d\n", (a + b + c + d) / 2);
		}
	}
	return 0;
}

基于Vue 3实现的Cesium大屏可视化项目源代码,展示了Cesium的一些基础示例,该项目是个人毕设项目,答辩评审分达到98分,代码都经过调试测试,确保可以运行!欢迎下载使用,可用于小白学习、进阶。该资源主要针对计算机、通信、人工智能、自动化等相关专业的学生、老师或从业者下载使用,亦可作为期末课程设计、课程大作业、毕业设计等。项目整体具有较高的学习借鉴价值!基础能力强的可以在此基础上修改调整,以实现不同的功能。 基于Vue 3实现的Cesium大屏可视化项目源代码,展示了Cesium的一些基础示例基于Vue 3实现的Cesium大屏可视化项目源代码,展示了Cesium的一些基础示例基于Vue 3实现的Cesium大屏可视化项目源代码,展示了Cesium的一些基础示例基于Vue 3实现的Cesium大屏可视化项目源代码,展示了Cesium的一些基础示例基于Vue 3实现的Cesium大屏可视化项目源代码,展示了Cesium的一些基础示例基于Vue 3实现的Cesium大屏可视化项目源代码,展示了Cesium的一些基础示例基于Vue 3实现的Cesium大屏可视化项目源代码,展示了Cesium的一些基础示例基于Vue 3实现的Cesium大屏可视化项目源代码,展示了Cesium的一些基础示例基于Vue 3实现的Cesium大屏可视化项目源代码,展示了Cesium的一些基础示例基于Vue 3实现的Cesium大屏可视化项目源代码,展示了Cesium的一些基础示例基于Vue 3实现的Cesium大屏可视化项目源代码,展示了Cesium的一些基础示例基于Vue 3实现的Cesium大屏可视化项目源代码,展示了Cesium的一些基础示例基于Vue 3实现的Cesium大屏可视化项目源代码,展示了Cesium的一些基础示例基于Vue 3实现的Cesium大屏可视化项目源代码,展示了
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值