蒟蒻求助
查看原帖
蒟蒻求助
798398
shapley楼主2023/1/13 17:45

跑了所有网上能找到的测试数据包括uDebug上的4组数据,都能通过。 实在不知道是啥问题了,求大神指点。

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<ctype.h>
#include<iomanip>
using namespace std;

struct Rect{
	int a; //长 
	int b; //宽 
	int n; //数量 
} rects[3];

int main() {
	#ifdef LOCAL
		//freopen("D:\\life\\学习\\编程\\C++\\算法竞赛入门经典\\3\\data.in", "r", stdin);
		//freopen("data.out", "w", stdout);
	#endif
	int a,b;
	
	while (cin >>a >>b){
		memset(rects,0,sizeof(rects));
		rects[0].a=a;
		rects[0].b=b;
		rects[1].a=a;
		rects[2].a=b;
		
		rects[0].n=1;
		int flag=0;
		for (int i=0; i<5; ++i){
			cin >>a >>b;
			int j=0;
			while(j<3){
				if (a==rects[j].a && b==rects[j].b && rects[j].n<2){
					++rects[j].n;
					break;
				}
				else if (b==rects[j].a && a==rects[j].b && rects[j].n<2){
					++rects[j].n;
					break;
				}					
				else if (rects[j].a==a && rects[j].b==0 && rects[j].n<2){
					rects[j].b=b;
					rects[j+1].b=b;
					++rects[j].n;
					break;
				}
				else if (rects[j].a==b && rects[j].b==0 && rects[j].n<2){
					rects[j].b=a;
					rects[j+1].b=a;
					++rects[j].n;
					break;
				}
				else ++j;					
			}
			if (j==3) flag=1;
		}
		 
		/*for (int i=0; i<3; ++i){
			//cout <<rects[i].a<<' '<<rects[i].b<<' '<<rects[i].n<<endl;
			if (rects[i].n==0){
				flag=1;
				break;
			}
		}*/
		
		if (flag)
			cout <<"IMPOSSIBLE"<<'\n';
		else
			cout <<"POSSIBLE"<<'\n';
	}
	return 0;
}
2023/1/13 17:45
加载中...