time limit per test
memory limit per test
Guy-Manuel and Thomas are going to build a polygon spaceship.
You’re given a strictly convex (i. e. no three points are collinear) polygon P
which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector (x,y)−→−−
. The picture below depicts an example of the translation:
as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that AB−→−=(x,y)−→−−. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y)
which contain the origin are drawn in colored:
The spaceship has the best aerodynamic performance if P
and T are similar. Your task is to check whether the polygons P and T
The first line of input will contain a single integer n
) — the number of points.
-th of the next n lines contains two integers xi,yi (|xi|,|yi|≤109), denoting the coordinates of the i
It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon.
Output “YES” in a separate line, if P
are similar. Otherwise, output “NO” in a separate line. You can print each letter in any case (upper or lower).
The following image shows the first sample: both P
are squares. The second sample was shown in the statements.
#define ll long long
using namespace std;
//typedef long long ll;
const int maxn=2e5+10;
pair<long long , long long> mp[maxn];
pair<long long ,long long > now,ans;
long long n;
cin >> mp[i].first >> mp[i].second;
mp[i].first = mp[i].first << 1;
mp[i].second = mp[i].second << 1;
if(n%2==1) return cout << "NO" << '\n' , 0;
now = make_pair((mp[1 + n / 2].first + mp.first) / 2 , (mp[1 + n / 2].second + mp.second) / 2);
ans = make_pair((mp[i + n / 2].first + mp[i].first) / 2 , (mp[i + n / 2].second + mp[i].second) / 2);
if(ans.first!=now.first||ans.second!=now.second) return cout << "NO" << '\n' , 0;