标签:swa bit pre 思路 name can ret ++ sort
注意,这道题思路可以把长宽确定好,短的放前面即可,然后用pair保存并排序,如果第一个和第二个,第三个和第四个,第五个和第六个相同且第一个的x和第二个的x,第一个的y和第三个的x,第二个的y和第三个的y相同才行,因为长方体三条边abc,设a<b<c,那么(a,b)排在最前面(a,c)边第二,(b,c)第三,这和pair的特性有关,先比第一个相同比第二个,这样,第一类的x就和第二类的x相同了,等等,不然无法成为长方体。
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x, y;
while(true)
{
bool flag = true;
vector<pair<int, int> > v;
for(int i = 0; i < 6; i++)
{
if(scanf("%d%d", &x, &y) == EOF)
return 0;
if(x > y)
swap(x, y);
v.push_back(make_pair(x, y));
}
sort(v.begin(), v.end());
for(int i = 0; i < 6; i += 2)
{
if(v[i] != v[i + 1])
flag = false;
}
if(!(v[0].first == v[2].first && v[0].second == v[4].first && v[2].second == v[4].second))
flag = false;
if(flag)
printf("POSSIBLE\n");
else
printf("IMPOSSIBLE\n");
}
return 0;
}
标签:swa bit pre 思路 name can ret ++ sort
原文地址:https://www.cnblogs.com/jacobfun/p/12885056.html