AC了
2024-06-29 14:30:23
发布于:浙江
4阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
inline int read(){
int f=1,x=0; char s=getchar();
while(s<'0' || s>'9') {if(s=='-')f=-1;s=getchar();}
while(s>='0' && s<='9') {x = x*10+s-'0';s=getchar();}
return x*f;
}
struct node{
int x,y;
void Read()
{
x = read(); y = read();
}
}a[20010];
int n;
bool cmp(node a,node b)
{
if (a.x == b.x) return a.y<b.y; else return a.x<b.x;
}
int main()
{
scanf("%d",&n);
long long sumx = 0 , sumy = 0;
for (int i = 1 ; i <= n ; i++) {
a[i].Read();
sumx += a[i].x; sumy += a[i].y;
}
double xx = sumx*1.0/n , yy = sumy*1.0/n;
int tx = floor(xx*2) , ty = floor(yy*2);
bool f = 1;
sort(a+1,a+1+n,cmp);
for (int i = 1 ; i <= n/2; i ++)
if (a[i].x+a[n-i+1].x != tx || a[i].y+a[n-i+1].y != ty)
{
f = 0;
break;
}
if (f == 1) printf("V.I.P. should stay at (%.1f,%.1f).\n",xx,yy);
else printf("This is a dangerous situation!");
return 0;
}
解释
这里空空如也
有帮助,赞一个