-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathUVA-1587.cpp
62 lines (59 loc) · 1.1 KB
/
UVA-1587.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;
struct point {
int x, y;
bool operator=(const point & rhs) const{
if(x == rhs.x && y == rhs.y)
return true;
return false;
}
bool operator<(const point & rhs) const {
if(x == rhs.x)
return y < rhs.y;
return x < rhs.x;
}
};
int main() {
int i,j,k,n,m;
point po;
bool flag;
while(scanf("%d %d",&po.x, &po.y) == 2) {
map<point, int> mp;
map<int, int> mp2;
if(po.x > po.y)
swap(po.x, po.y);
mp[po]++;
mp2[po.x]++;
mp2[po.y]++;
for(i=0;i<5;++i) {
scanf("%d %d", &po.x, &po.y);
if(po.x > po.y)
swap(po.x, po.y);
mp2[po.x]++;
mp2[po.y]++;
mp[po]++;
}
flag = true;
for(auto pi = mp.begin(); pi != mp.end(); ++pi) {
//printf("%d %d %d\n", pi->first.x, pi->first.y, pi->second);
if(pi->second % 2 != 0) {
flag = false;
break;
}
}
for(auto pi = mp2.begin(); pi != mp2.end(); ++pi) {
//printf("[%d %d] ", pi->first, pi->second);
if(pi->second % 4 != 0) {
flag = false;
break;
}
}
if(flag)
puts("POSSIBLE");
else
puts("IMPOSSIBLE");
}
return 0;
}