2015北京邀请赛 UVALive7267 Mysterious Antiques in Sackler Museum

呀,再次展示了英文不好的问题。我一直以为是选三个,问是否可以刚好完美塞进第四个矩形里面。因为我看到了这一句Maybe the one who could pick exactly three pieces of those bones to form a larger rectangle was considered smart at that time。

但是题意是,选出三个,看看是否可以凑成一个新的矩形。

然后就删了删,改了改,就好了,完全用暴力去模拟。

代码如下:

#include<bits/stdc++.h>
using namespace std;

struct node
{
	int cnt[2];
}a[5];

bool Check(node x, node y, node z)
{
	for(int i = 0; i < 2; i++)
		for(int j = 0; j < 2; j++)
			for(int k = 0; k < 2; k++)
				if(x.cnt[i^1] == y.cnt[j^1] && x.cnt[i] + y.cnt[j] == z.cnt[k])
					return 1;
				else if(x.cnt[i] == y.cnt[j] && y.cnt[j] == z.cnt[k])
					return 1;
	return 0; 
}

int main()
{
	bool flag;
	int T;
	cin >> T;
	while(T--)
	{
		flag = 0;
		for(int i = 0; i < 4; i++)
			scanf("%d%d", &a[i].cnt[0], &a[i].cnt[1]);
		for(int i = 0; i < 4; i++)
			for(int j = 0; j < 4; j++)
				for(int k = 0; k < 4; k++)
				{
					if(i == j || j == k || i == k)
						continue;
					if(Check(a[i], a[j], a[k]))
						flag = 1;
				}
		if(flag)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值