找规律-洛谷P1227 [JSOI2008]完美的对称
https://daniu.luogu.org/problem/show?pid=1227#sub
这个其实只要x,y二目排序一下就好啦;
拍好后取两端的值算中心再验证一下就好啦;
太显然了;
因为你按x轴排序可以找到最高点和最低点,如果有多个用y去排序区分,那么拍好后两个端点显然是一组点;
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#define Ll long long
using namespace std;
struct ss{
int x,y;
}a[20005];
int n;
bool cmp(ss x,ss y){if(x.x!=y.x)return x.x<y.x;return x.y<y.y;}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].y);
sort(a+1,a+n+1,cmp);
double x,y;
x=(a[1].x+a[n].x)/(double)2;
y=(a[1].y+a[n].y)/(double)2;
for(int i=2;i<=n/2;i++)
if(x!=(a[i].x+a[n-i+1].x)/(double)2||y!=(a[i].y+a[n-i+1].y)/(double)2){printf("This is a dangerous situation!");return 0;}
if(n&1)if(a[n/2+1].x!=x||a[n/2+1].y!=y){printf("This is a dangerous situation!");return 0;}
printf("V.I.P. should stay at (%.1lf,%.1lf).",x,y);
}