您的位置:首页 > 其它

UVa1587 Box

2015-06-26 08:39 435 查看
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
set<int> s; // 12个数字中不能出现3个以上不同的值,最多只有三种值:长、宽、高
int face[6];
int i = 0, w, h;
while (cin >> w >> h)
{
if (s.size() <= 3)
{
s.insert(w);
s.insert(h);
if (w > h)
face[i] = (h << 16) | w; // 充分利用条件 1 <= w,h <= 10000
else
face[i] = (w << 16) | h;
}

if (++i == 6)
{
if (s.size() <= 3)
{
sort(face, face+6);
for (i = 0; i < 6; i += 2)
{ // 判断是否存在3对相等的面
if (face[i] != face[i+1])
break;
}
if (i == 6)
cout << "POSSIBLE" << endl;
else
cout << "IMPOSSIBLE" << endl;
}
else
{
cout << "IMPOSSIBLE" << endl;
}
i = 0;
s.clear();
}
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: