View Code of Problem 3928

#include <stdio.h>
#include <stdlib.h>
struct fang
{
	int max;
	int min;
};

int cmp(const void*a,const void*b)
{
	if((*(struct fang*)a).min==(*(struct fang*)b).min)
	{
		if((*(struct fang*)a).max-(*(struct fang*)b).max>0)
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	else
	{
		if((*(struct fang*)a).min-(*(struct fang*)b).min>0)
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
}




int main()
{
	int tempa,tempb;
	while(scanf("%d%d",&tempa,&tempb)!=EOF)
	{
		int temp;
		int flag=0;
		struct fang f[6];
		if(tempa<tempb)
		{
			temp=tempa;
			tempa=tempb;
			tempb=temp;
		}
		f[0].max=tempa;
		f[0].min=tempb;
		for(int i=1;i<=5;i++)
		{
			scanf("%d%d",&tempa,&tempb);
			if(tempa<tempb)
			{
				temp=tempa;
				tempa=tempb;
				tempb=temp;
			}
			f[i].max=tempa;
			f[i].min=tempb;
		}
		qsort(f,6,sizeof(f[0]),cmp);
		/*for(int i=0;i<6;i++)
		{
			printf("%d %d %d\n",i,f[i].min,f[i].max);
		}*/
		
		
		
		
		if(f[0].min==f[1].min&&f[0].min==f[2].min&&f[0].min==f[3].min)
		{
			if(f[0].max==f[1].max&&f[0].max==f[4].min)
			{
				if(f[2].max==f[3].max&&f[2].max==f[4].max)
				{
					if(f[4].min==f[5].min&&f[4].max==f[5].max)
					{
						flag=1;
					}
				}
			}
		}
		if(flag)
		{
			printf("POSSIBLE\n");
		}
		else
		{
			printf("IMPOSSIBLE\n");
		}
		
	}
 } 

Double click to view unformatted code.


Back to problem 3928