大佬们救救,测试过但WA
查看原帖
大佬们救救,测试过但WA
1103873
FHY_XiongZhen楼主2023/10/8 23:33
#include<iostream>

using namespace std;

class pallet {
public:
	int h;
	int w;
	pallet() { h = 0; w = 0;}
	pallet(int n1, int n2) {
		h = max(n1, n2);
		w = min(n1, n2);
	}
	bool operator==(pallet another) {
		if (this->h == another.h && this->w == another.w) {
			return true;
		}
		return false;
	}
};

pair<pallet, int> p[20];

bool initalize() {
	int j = 0;
	for (int i = 0; i < 6; i++) {
		int n1, n2;
        if (i == 0) {
            if (scanf("%d", &n1) == EOF)
                exit(0);
        } 
        else {
            scanf("%d", &n1);
        }
		scanf("%d", &n2);
		bool flag = true;
		for (int t = 0; t < j; t++) {
			if (pallet(n1, n2) == p[t].first && p[t].second < 2) {
				flag = false;
				p[t].second++;
				break;
			}
		}
		if (flag) {
			p[j].second++;
			p[j++].first = pallet(n1, n2);
		}
	}
	if (p[0].second == 2 && p[1].second == 2 && p[2].second == 2) {
        //cout <<" haha"<<endl;
		return true;
	}
	return false;
}

bool judge() {
	int x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0;
	x1 = p[0].first.h;
	y1 = p[0].first.w;
	int i;
	for (i = 1; i < 3; i++) {
		if (x1 == p[i].first.h) {
			x3 = p[i].first.h;
			y3 = p[i].first.w;
			break;
		}
		else if (x1 == p[i].first.w) {
			x3 = p[i].first.w;
			y3 = p[i].first.h;
			break;
		}
	}
	int r = 1;
	if (i == 1) { r = 2; }
	if (y1 == p[r].first.h) {
		x2 = p[r].first.h;
		y2 = p[r].first.w;
	}
	else if (y1 == p[r].first.w) {
		x2 = p[r].first.w;
		y2 = p[r].first.h;
	}
    //cout << x1 << ' ' << x2 << ' ' << x3 << ' ' << y1 << ' ' << y2 << ' ' << y3 << endl;
	if (x1 && x2 && x3 && y1 && y2 && y3 && y2 == y3) {
		return true;
	}
	return false;
}

void resetData() {
    for (int i = 0; i < 3; i++) {
        p[i].second = 0;
        p[i].first.h = 0;
        p[i].first.w = 0;
    }
}

int main() {
    while (1) {
    	if (initalize() && judge()) { cout << "POSSIBLE" << endl; }
	    else { cout << "IMPOSSIBLE" << endl; }
        resetData();
    }
	return 0;
}
2023/10/8 23:33
加载中...