The idea of this problem is clear or not difficult, the key is to judge the method.
Cuboid has three different sides, we remember as ABC, and remember A>b>c, then the cuboid of the six faces must be AB, AB, AC, AC, BC, BC (according to the length of the order), in line with this form is a cuboid.
According to the topic, the emphasis is on how to convert the input data into this standard form and then make a judgment.
First, the size of each side of the two edge to figure out, such as BA conversion to AB, that is, long > wide;
Then the six faces are sorted, sorted by length from big to small, the same length, sorted by width;
Next to judge, the cuboid contains a "three-pair" face, and the length or width of the opposite is equal to the length or width of another pair of faces, the condition is cuboid.
#include <bits/stdc++.h>
using namespace std;
struct face{
int x, y;
}a[6];
bool check()
{
if(memcmp(a, a+1, sizeof(face)) || memcmp(a+2, a+3, sizeof(face)) || memcmp(a+4, a+5, sizeof(face))) return false;
if(a[0].x!=a[2].x || a[0].y!= a[4].x || a[2].y!=a[4].y) return false;
return true;
}
int main()
{
while(cin >> a[0].x >> a[0].y >> a[1].x >> a[1].y >> a[2].x >> a[2].y >> a[3].x >> a[3].y >> a[4].x >> a[4].y >> a[5].x >> a[5].y){
for(int i = 0; i < 6; ++i)
if(a[i].x < a[i].y)
swap(a[i].x, a[i].y);
sort(a, a+6, [](const face a, const face b) {return a.x==b.x ? (a.y > b.y) : (a.x > b.x);});
printf("%s\n", check() ? "POSSIBLE" : "IMPOSSIBLE");
}
return 0;
}