View Code of Problem 3928

#include<iostream>
#include<algorithm>
using namespace std;
struct node{
	int x;
	int y;
};
bool cmp(struct node x,struct node y){
	if(x.x==y.x)
	return x.y<y.y;
	return x.x<y.x;
}
int main(){
	struct node a[6];
	int x;
	while(cin>>x){
		a[0].x=x;
		for(int i=0;i<6;++i){
				if(i==0){
					scanf("%d",&a[i].y);
				}
				else
				scanf("%d %d",&a[i].x,&a[i].y);
				if(a[i].x>a[i].y)
				swap(a[i].x,a[i].y);
		}
		sort(a,a+6,cmp);
		int f=0;
		if(a[0].x==a[1].x&&a[1].x==a[2].x&&a[2].x==a[3].x)
			if(a[4].x==a[5].x&&a[5].x==a[0].y&&a[0].y==a[1].y)
				if(a[2].y==a[3].y&&a[3].y==a[4].y&&a[4].y==a[5].y)
					f=1;
		if(f)
		printf("POSSIBLE\n");
		else
		printf("IMPOSSIBLE\n");
	}
}

Double click to view unformatted code.


Back to problem 3928