代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<set>
#include<stack>
#include<algorithm>
#include<cstdlib>
#define maxn 20
using namespace std;
struct Node
{
int x,y;
}st[maxn];
int cmp(Node a,Node b)
{
if (a.x==b.x)
return a.y<b.y;
return a.x<b.x;
}
int main()
{
int a,b;
while (~scanf("%d",&a))
{
int flag=1;
scanf("%d",&b);
if (a>b) swap(a,b);
st[0].x=a,st[0].y=b;
for (int i=1;i<6;i++)
{
scanf("%d%d",&a,&b);
if (a>b) swap(a,b); //把较小的边放在前面
st[i].x=a; st[i].y=b;
}
sort(st,st+6,cmp); //排序
for (int i=0;i<6;i+=2)
{
if (!(st[i].x==st[i+1].x&&st[i].y==st[i+1].y)) //如果每两个相邻的面的x和y不相等一定不满足
{
flag=0;
break;
}
}
if (flag)
{
if (st[0].x!=st[2].x) //不同面的最小的两条边不能重合的不满足
flag=0;
if (!((st[0].y==st[4].x&&st[2].y==st[4].y)||(st[0].y==st[4].y&&st[2].y==st[4].x)))//判断第三个面能否与前两个面相接
flag=0;
}
if (flag)
printf("POSSIBLE\n");
else
printf("IMPOSSIBLE\n");
}
return 0;
}