View Code of Problem 3928

#include<iostream>
#include<algorithm>
using namespace std;

typedef struct {
	int min;
	int max;
	int flag = 0;
}Plane;

bool cmp(Plane a, Plane b) {
	if (a.min == b.min) {
		return a.max < b.max;
	}
	return a.min < b.min;
}

bool compare(Plane a, Plane b) {
	if (a.min == b.min&&a.max == b.max) {
		return true;
	}
	return false;
}

int main() {
	int w, h;
	int count = 0;
	Plane p[6];
	while (cin>>w>>h){
		p[count].min = min(w, h);
		p[count].max = max(w, h);
		count++;
		if (count >= 6) {
			int flag = 0;
			count = 0;
			sort(p, p + 6, cmp);
			for (int i = 0;i < 6;i+=2) {
				if (compare(p[i], p[i + 1])) {
					flag++;
				}
			}
			if (flag == 3&&p[4].min==p[0].max&&p[4].max==p[2].max) {
				cout << "POSSIBLE" << endl;
			}
			else {
				cout << "IMPOSSIBLE" << endl;
			}
		}
	}
}

Double click to view unformatted code.


Back to problem 3928