[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; }
相关文章推荐
- 计算几何瞎暴力——Luogu1227 [JSOI2008]完美的对称
- 洛谷 P1227 [JSOI2008]完美的对称
- [JSOI2008]完美的对称{数论}
- [JSOI2008] [洛谷P1227] 完美的对称|乱搞
- 洛谷 P1227 [JSOI2008]完美的对称
- 洛谷 P1227 [JSOI2008]完美的对称
- 洛谷 P1227 [JSOI2008]完美的对称
- 找规律-洛谷P1227 [JSOI2008]完美的对称
- [JSOI2008]完美的对称 题解
- luoguP1198 [JSOI2008]最大数
- [luoguP4035] [JSOI2008]球形空间产生器(高斯消元)
- [luoguP1198][JSOI2008] 最大数(线段树 || 单调栈)
- [luoguP1197] [JSOI2008]星球大战(并查集)
- luoguP1197 [JSOI2008]星球大战 x
- Cogs 1844. [JSOI2008]最大数maxnumber
- BZOJ 1013: [JSOI2008]球形空间产生器sphere
- BZOJ 1567: [JSOI2008]Blue Mary的战役地图 Hash+set
- P4208 [JSOI2008]最小生成树计数
- P1198 [JSOI2008]最大数
- BZOJ 1570: [JSOI2008]Blue Mary的旅行( 二分答案 + 最大流 )