呀,再次展示了英文不好的问题。我一直以为是选三个,问是否可以刚好完美塞进第四个矩形里面。因为我看到了这一句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;
}