D. Aerodynamic

Codeforces Round 618 (Div. 2) D. Aerodynamic
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 . The picture below depicts an example of the translation:

Define T 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 . 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 are similar(相似).
Input
The first line of input will contain a single integer n () — the number of points.

The i-th of the next n lines contains two integers (), denoting the coordinates of the i-th vertex.

It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon.

Output
Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower).

Examples
input
4
1 0
4 1
3 4
0 3
output
YES
input
3
100 86
50 0
150 0
output
nO
input
8
0 0
1 0
2 1
3 3
4 6
3 6
2 5
1 3
output
YES
Note
The following image shows the first sample: both P and T are squares. The second sample was shown in the statements.

Problem solving:
这道题的意思就是给你一个n边形,这个n边形可以在坐标轴上任意移动。问你当这个n变形的某一个顶点移动到原点时,剩下的可以得到2*n个点,问你这个n边形与2*n个点组成的多边形是否相似。
因为2*n边形的边肯定是偶数,所以如果n是奇数的话直接就是不可以的。
当n为偶数时,如果这个n边形是中心对称图形,才会满足相似。这些顶点还是按照逆时针顺序给出的,所以我们只需要根据n/2条由顶点连接起来的线的中点是否相同即可。

Code:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
ll        a[maxn], b[maxn];
int main()
{
    ios::sync_with_stdio(0);
    ll n;
    cin >> n;
    for (ll i = 1; i <= n; i++)
        cin >> a[i] >> b[i];
    if (n & 1)
    {
        cout << "NO\n";
    }
    else
    {
        ll mmp = a[1] + a[n / 2 + 1], mmmp = b[1] + b[n / 2 + 1], flag = 0;
        for (ll i = 2; i <= n / 2; i++)
        {
            ll m = a[i] + a[i + n / 2], mp = b[i] + b[i + n / 2];
            if (m != mmp)
                flag = 1;
            if (mp != mmmp)
                flag = 1;
        }
        if (flag)
            cout << "NO\n";
        else
            cout << "YES\n";
    }
    return 0;
}