Codeforces Round 1300 D Aerodynamic(思维+中学数学)

D. Aerodynamic
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output

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:
在这里插入图片描述

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 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 are similar.

Input
The first line of input will contain a single integer n (3≤n≤105) — the number of points.

The i-th of the next n lines contains two integers xi,yi (|xi|,|yi|≤109), 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
inputCopy
4
1 0
4 1
3 4
0 3
outputCopy
YES
inputCopy
3
100 86
50 0
150 0
outputCopy
nO
inputCopy
8
0 0
1 0
2 1
3 3
4 6
3 6
2 5
1 3
outputCopy
YES
Note
The following image shows the first sample: both P and T are squares. The second sample was shown in the statements.

在这里插入图片描述
ac程序参考:


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxnn=1e5+50;
ll x[maxnn],y[maxnn];
int n;

int judge()
{
    for(int i=1;i<=n/2;i++)
	{
        int j=i+n/2;
        int vi=i+1;
        int vj=j%n+1;
        if(1ll*(y[i]-y[vi])*(x[j]-x[vj])!=1ll*(y[j]-y[vj])*(x[i]-x[vi]))
            return 0;
        ll ansi=1ll*(x[i]-x[vi])*(x[i]-x[vi])+1ll*(y[i]-y[vi])*(y[i]-y[vi]);
        ll ansj=1ll*(x[j]-x[vj])*(x[j]-x[vj])+1ll*(y[j]-y[vj])*(y[j]-y[vj]);
        if(ansi!=ansj) return 0;
    }
    return 1;
}

int main()
{	cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>x[i]>>y[i];
    if(n%2==0 && judge()) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值