forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeometry.cpp
101 lines (84 loc) · 1.82 KB
/
geometry.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <bits/stdc++.h>
using namespace std;
void rotate(deque<pair<int,int>>& p) {
int w = 0;
for(auto i : p) {
w = max(w,i.first);
}
for(auto& i : p) {
pair<int,int> t = {i.second,w-i.first};
i = t;
}
}
void compress(deque<pair<int,int>>& p) {
vector<int> x;
vector<int> y;
for(auto i : p) {
x.push_back(i.first);
y.push_back(i.second);
}
sort(x.begin(),x.end());
sort(y.begin(),y.end());
x.erase(unique(x.begin(),x.end()),x.end());
y.erase(unique(y.begin(),y.end()),y.end());
map<int,int> convx;
map<int,int> convy;
for(int i = 0; i < x.size(); i++) {
convx[x[i]] = i;
}
for(int i = 0; i < y.size(); i++) {
convy[y[i]] = i;
}
for(auto& i : p) {
i.first = convx[i.first];
i.second = convy[i.second];
}
}
bool equal(deque<pair<int,int>>& d1, deque<pair<int,int>>& d2) {
for(int i = 0; i < d2.size(); i++) {
if(d1 == d2) return true;
d2.push_front(d2.back());
d2.pop_back();
}
return false;
}
int main() {
int n1;
cin >> n1;
deque<pair<int,int>> p1(n1);
for(auto& i : p1) {
cin >> i.first >> i.second;
}
int n2;
cin >> n2;
deque<pair<int,int>> p2(n2);
for(auto& i : p2) {
cin >> i.first >> i.second;
}
if(n1 != n2) {
cout << "no" << endl;
return 0;
}
compress(p1);
compress(p2);
if(equal(p1,p2)) {
cout << "yes" << endl;
return 0;
}
rotate(p2);
if(equal(p1,p2)) {
cout << "yes" << endl;
return 0;
}
rotate(p2);
if(equal(p1,p2)) {
cout << "yes" << endl;
return 0;
}
rotate(p2);
if(equal(p1,p2)) {
cout << "yes" << endl;
return 0;
}
cout << "no" << endl;
}