要点

  • 结论:如果坐标系一堆点两两对称于某一重心,则排序后第1个和第n个为一对,以此类推。
  • 枚举所有可能的重心点并check。因为隐藏的点不超过k个,所以点1~k+1都可能跟第n个匹配。对右侧同样适用,因此枚举的点是\(k^2\)的。内部只要两边开始扫描,如果匹配不是当前重心则说明他俩不是一对,则加一个虚点(cnt++),最后加的虚点数不超过k即true。
#include <cstdio>
#include <algorithm>
#include <set>
#define fir first
#define sec second
using namespace std; typedef pair<int, int> pii;
const int maxn = 2e5 + 5;
int n, k;
pii p[maxn];
set<pii> s; pii operator + (pii A, pii B) {
return {A.fir + B.fir, A.sec + B.sec};
} bool operator == (pii A, pii B) {
return A.fir == B.fir && A.sec == B.sec;
} bool operator < (pii A, pii B) {
if (A.fir != B.fir) return A.fir < B.fir;
return A.sec < B.sec;
} void check(int l, int r) {
int cnt = 0;
pii point = p[l] + p[r];
l = 1, r = n; while (l <= r) {
if (point == p[l] + p[r]) {
l++, r--;
} else if (point < p[l] + p[r]) {
cnt++, r--;
} else {
cnt++, l++;
}
} if (cnt <= k)
s.insert(point);
} int main() {
scanf("%d %d", &n, &k);
for (int i = 1; i <= n; i++)
scanf("%d %d", &p[i].fir, &p[i].sec);
if (n <= k) return !printf("-1\n"); sort(p + 1, p + 1 + n); for (int i = 1; i <= k + 1; i++)
for (int j = n - k; j <= n; j++)
check(i, j); printf("%d\n", (int)s.size());
for (auto i : s)
printf("%.8lf %.8lf\n", (double)i.fir / 2.0, (double)i.sec / 2.0);
}

Codeforces 140F(坐标系点对称)的更多相关文章

  1. Codeforces Gym 100531J Joy of Flight 变换坐标系

    Joy of Flight 题目连接: http://codeforces.com/gym/100531/attachments Description Jacob likes to play wit ...

  2. Codeforces Round #524 (Div. 2)C 二维坐标系求俩矩形面积交

    题:https://codeforces.com/contest/1080/problem/C 题意:给n*m的二维坐标系,每个位置(xi,yi)都表示一个方格,(1,1)的位置是白色,整个坐标系黑白 ...

  3. Codeforces 183A(坐标系性质)

    自从开始写上古场以后我就不断地写A.B题的题解了??? cf problem183A 无论每轮有哪几种选择,最后的可能结果放在一起一定是个钻石型,最后答案就是长方形长乘宽. 非常神奇的性质,如果走了e ...

  4. CodeForces - 76F:Tourist (旋转坐标系,LIS)

    pro:有一个驴友,以及给定N个表演地点xi和时间ti,驴友的速度不能超过V. 问他在起点为原点和不设置起点的情况下分别最多参观多少个表演. sol:BZOJ接飞饼见过:clari也在camp的DP专 ...

  5. Codeforces 271 Div 2 C. Captain Marmot

    题目链接:http://codeforces.com/contest/474/problem/C 解题报告:给一个n,然后输入4*n个平面坐标系上的点,每四个点是一组,每个点有一个中心,这四个点可以分 ...

  6. Codeforces Gym 100463D Evil DFS

    Evil Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463/attachments Descr ...

  7. Codeforces Round #327 (Div. 2) D. Chip 'n Dale Rescue Rangers 二分 物理

    D. Chip 'n Dale Rescue Rangers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/co ...

  8. Codeforces Round #322 (Div. 2) B. Luxurious Houses 水题

    B. Luxurious Houses Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/pr ...

  9. 状压dp Codeforces Beta Round #8 C

    http://codeforces.com/contest/8/problem/C 题目大意:给你一个坐标系,给你一个人的目前的坐标(该坐标也是垃圾桶的坐标),再给你n个垃圾的坐标,这个人要捡完所有的 ...

随机推荐

  1. BZOJ 1202 [HNOI2005]狡猾的商人:并查集(维护距离)

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1202 题意: 有一个账本,记录了n个月的盈亏. 每个月的数值:正为盈,负为亏. 你知道m个 ...

  2. python学习笔记:第六天(流程控制语句)

    Python3 条件控制 1.if 语句 <1> 一般形式 Python中if语句的一般形式如下所示: if condition_1: statement_block_1 elif con ...

  3. Css公共文件结构

    一般一个网站会有这么三个样式: global.css | reset.css(格式化样式) common.css(公共组件样式) layout.css(当前页面样式) 清除全站所有页面的浏览器默认样式 ...

  4. springmvc的简单介绍以及springmvc组件的介绍

    Spring web mvc框架 什么是springmvc Springmvc是spring框架的一个模块,spring和springmvc无需中间整合层整合 Springmvc是一个基于mvc的we ...

  5. c macro pair

    成对使用的macro, 不过也有机会用错, 死都不知道怎么死的, 这宏... #define pthread_cleanup_push(func, val) \ { \ struct __darwin ...

  6. Linux下Fork与Exec

    一.引言 对于没有接触过Unix/Linux操作系统的人来说,fork是最难理解的概念之一:它执行一次却返回两个值.fork函数是Unix系统最杰出的成就之一,它是七十年代UNIX早期的开发者经过长期 ...

  7. ubuntu 安装cuda 成功

    洗洗睡了

  8. ACM学习历程—HDU 4287 Intelligent IME(字典树 || map)

    Description We all use cell phone today. And we must be familiar with the intelligent English input ...

  9. bzoj1853幸运数字——容斥原理

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1853 dfs实现容斥原理即可. 注意:若在init中写“cnt++”,则出来后需要先cnt-- ...

  10. MFC中界面自适应

    void CMyDlg::OnSize(UINT nType, int cx, int cy){ CDialogEx::OnSize(nType, cx, cy); CRect rt; GetClie ...