用的最笨的暴力的方法,看了以前写的代码比较短但是也没有心思去搞明白怎么回事了
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pa;
bool cmp(pa a, pa b) {
if (a.fi != b.fi) return a.fi < b.fi;
else return a.se < b.se;
}
int main() {
pa p[6];
while (cin >> p[0].fi >> p[0].se) {
if (p[0].fi > p[0].se) swap(p[0].fi, p[0].se);
for (int i = 1; i < 6; i++) {
cin >> p[i].fi >> p[i].se;
if (p[i].fi > p[i].se) swap(p[i].fi, p[i].se);
}
sort(p, p + 6, cmp);
if (p[0] != p[1] || p[2] != p[3] || p[4] != p[5]) {
cout << "IMPOSSIBLE" << endl;
continue;
}
pa a = p[0], b = p[2], c = p[4];
int ok = 0;
if (a.fi == b.fi) {
if (a.se == c.fi && b.se == c.se) ok = 1;
if (a.se == c.se && b.se == c.fi) ok = 1;
} else if (a.fi == b.se) {
if (a.se == c.fi && b.fi == c.se) ok = 1;
if (a.se == c.se && b.fi == c.fi) ok = 1;
} else if (a.fi == c.fi) {
if (a.se == b.fi && b.se == c.se) ok = 1;
if (a.se == b.se && b.fi == c.se) ok = 1;
} else if (a.fi == c.se) {
if (a.se == b.fi && b.se == c.fi) ok = 1;
if (a.se == b.se && b.fi == c.fi) ok = 1;
}
cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}
return 0;
}