要点

  • 结论:如果坐标系一堆点两两对称于某一重心,则排序后第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. 国际电话号码的区号mysql数据表

    -- phpMyAdmin SQL Dump-- version 3.5.2-- http://www.phpmyadmin.net---- Host: localhost-- Generation ...

  2. Nginx HTTP Server相关

    一.Nginx安装: 采取手动编译安装 对多种重要的选项进行配置 安装前提:常用工具和库,GCC PCRE(Rewrite模块需要) pcre-devel(源码) zlib zlib-devel(源码 ...

  3. 取分组TOPN好理解案例

  4. 使用Tornado作为Django App的服务器

    闲来无事,折腾折腾. 老是听说tonado是个异步web框架和服务器,作为框架倒是了解到了,但是服务器一直不太懂.所以决定了解一下,既然可以做服务器,那就把自己的django app部署到这上边去. ...

  5. 2012年浙大:Head of a Gang

    题目描述: One way that the police finds the head of a gang is to check people's phone calls. If there is ...

  6. echo命令的简单用法和实例

    在CentOS 6.8版本下,通过实例的形式,展现选项和参数的灵活运用,可以简明的了解echo的用法. 一.语法:echo [SHORT-OPTION]… [STRING]… :echo [选项]…[ ...

  7. Java中的IO流(1)

    字节流: //一个字节一个字节的读写 FileInputStream in=new FileInputStream("源文件"); FileOutputStream out=new ...

  8. python斐波拉契数列

    def fib(max): n, a, b = 0, 0, 1 while n < max: print(b) a, b = b, a + b n = n + 1 return 'done' 注 ...

  9. 托管C++——在C#中使用C++

    下面就用一个完整的实例来详细说明怎样用托管C++封装一个C++类以提供给C#使用. 现有一个Detector类需要使用,首先,要创建一个托管C++的DLL工程DAADll,然后在里面添加下面的代码: ...

  10. F - 棋盘问题

    F - 棋盘问题 Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Sta ...