题解:CF1299B Aerodynamic

· · 题解

:::info[题意] 给定一个严格凸多边形 P。定义多边形 T,当且仅当 \overrightarrow{AB} = \overrightarrow{(x, y)} (A, B \in P)。求 T 是否与 P 相似。 :::

:::info[题解]{open} 结论:P 一定是中心对称图形。

必要性:

(如果 T 和 P 相似,P 一定是中心对称图形。)

对于任意的 A,B \in P,若 \overrightarrow{AB} \in T,则一定有 \overrightarrow{BA} \in T。也就是说 T 一定是中心对称图形。要使 T 与 P 相似,则 P 也是中心对称图形。

充分性:

(如果 P 是中心对称图形,则 T 一定与 P 相似。)

我们考虑这样定义相似。 若 P 任意两点组成的差向量都在 T 中存在,且 T 任意两点组成的差向量都在 P 中存在,则 P 和 T 一定相似,显然这道题存在这种关系。

:::info[代码]

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int n,a[maxn],b[maxn],p,cx,cy;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i];
    }
    if(n&1){
        cout<<"No"<<endl;
        return 0;
    }
    p=n/2;
    cx=a[1]+a[p+1],cy=b[1]+b[p+1];
    for(int i=2;i<=p;i++){
        if((a[i]+a[p+i])!=cx||(b[i]+b[p+i])!=cy){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

:::