您的位置:首页 > Web前端 > JavaScript

[luoguP1227] [JSOI2008]完美的对称(sort)

2017-09-09 15:26 585 查看

传送门

 

排序!

 

#include <cstdio>
#include <iostream>
#include <algorithm>
#define N 20001

int n;

struct node
{
double x, y;
}a
, b
;

inline int read()
{
int x = 0, f = 1;
char ch = getchar();
for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
for(; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
return x * f;
}

inline bool cmp1(node x, node y)
{
return x.x < y.x || (x.x == y.x && x.y < y.y);
}

inline bool cmp2(node x, node y)
{
return x.x > y.x || (x.x == y.x && x.y > y.y);
}

int main()
{
int i;
double x, y;
n = read();
for(i = 1; i <= n; i++)
{
a[i].x = b[i].x = read();
a[i].y = b[i].y = read();
}
std::sort(a + 1, a + n + 1, cmp1);
std::sort(b + 1, b + n + 1, cmp2);
x = a[1].x + b[1].x;
y = a[1].y + b[1].y;
for(i = 2; i <= n; i++)
if(a[i].x + b[i].x != x || a[i].y + b[i].y != y)
{
puts("This is a dangerous situation!");
return 0;
}
x /= 2.0;
y /= 2.0;
printf("V.I.P. should stay at (%.1lf,%.1lf).\n", x, y);
return 0;
}

  

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: