发现由于角的度数和边的长度有限制,那俩圆如果放得下的话,必然是塞在两个角里。

于是预处理n个圆心的位置(注意要判断那个圆会不会和其他的边界相交),然后n^2枚举俩角即可。

#include<cstdio>
#include<cmath>
using namespace std;
#define EPS 0.00000001
struct Point{
double x,y;
double length(){
return sqrt(x*x+y*y);
}
}a[2010];
typedef Point Vector;
Vector unit(Vector v){
double l=v.length();
return (Vector){v.x/l,v.y/l};
}
Vector operator - (const Point &a,const Point &b){
return (Vector){a.x-b.x,a.y-b.y};
}
Vector operator + (const Point &a,const Point &b){
return (Vector){a.x+b.x,a.y+b.y};
}
double dot(const Vector &a,const Vector &b){
return a.x*b.x+a.y*b.y;
}
double Cross(const Vector &a,const Vector &b){
return a.x*b.y-a.y*b.x;
}
Vector operator * (const double &K,const Vector &v){
return (Vector){K*v.x,K*v.y};
}
int n;
Point calc(int I){
double jiao=acos(dot(a[I+1]-a[I],a[I-1]-a[I])/(a[I+1]-a[I]).length()/(a[I-1]-a[I]).length());
double d=4000.0/tan(jiao/2.0);
double l=4000.0/sin(jiao/2.0);
Point p1=a[I]+d*unit(a[I+1]-a[I]);
Point p2=a[I]+d*unit(a[I-1]-a[I]);
Point M=(Point){(p1.x+p2.x)/2.0,(p1.y+p2.y)/2.0};
return a[I]+l*unit(M-a[I]);
}
double DisToSegment(Point P,Point A,Point B)
{
Vector v1=B-A,v2=P-A,v3=P-B;
if(dot(v1,v2)<EPS) return v2.length();
else if(dot(v1,v3)>EPS) return v3.length();
else return fabs(Cross(v1,v2))/v1.length();
}
Point yuanxins[2010];
bool can[2010];
int main(){
// freopen("k.in","r",stdin);
scanf("%d",&n);
for(int i=1;i<=n;++i){
scanf("%lf%lf",&a[i].x,&a[i].y);
}
a[++n]=a[1];
for(int i=n;i>=1;--i){
a[i+1]=a[i];
}
a[1]=a[n];
++n;
for(int i=2;i<n;++i){
yuanxins[i]=calc(i);
can[i]=1;
for(int j=2;j<n;++j){
// double tmp=DisToSegment(yuanxins[i],a[j],a[j+1]);
if(DisToSegment(yuanxins[i],a[j],a[j+1])-4000.0<-EPS){
can[i]=0;
break;
}
}
}
for(int i=2;i<n;++i){
if(Cross(a[i+1]-a[i],a[i]-a[i-1])>EPS && can[i]){
Point A=yuanxins[i];
for(int j=i+1;j<n;++j){
if(Cross(a[j+1]-a[j],a[j]-a[j-1])>EPS && can[j]){
Point B=yuanxins[j];
// double tmp=(B-A).length();
if((B-A).length()-8000.0>-EPS){
printf("%.8f %.8f\n%.8f %.8f\n",A.x,A.y,B.x,B.y);
return 0;
}
}
}
}
}
puts("impossible");
return 0;
}

【计算几何】【预处理】【枚举】Urozero Autumn Training Camp 2016 Day 5: NWERC-2016 Problem K. Kiwi Trees的更多相关文章

  1. 【枚举】【SPFA】Urozero Autumn Training Camp 2016 Day 5: NWERC-2016 Problem I. Iron and Coal

    那个人派出的队伍的行走的路径一定前半程是重合的,后半程分叉开来. 于是预处理每个点离1号点的最短路,到最近的铁的最短路,到最近的煤的最短路.(三次BFS / SPFA)然后枚举分岔点,尝试更新答案即可 ...

  2. 【强连通分量缩点】【DFS】【动态规划】Urozero Autumn Training Camp 2016 Day 5: NWERC-2016 Problem B. British Menu

    有向图,不经过重复点的最长链,强连通分量大小不超过5. 每个强连通分量内部暴力预处理任意两对点之间的最长路,外面DAG上dp. 不是很好写,但是预处理完了之后,可以重构每个强连通分量内部的结构,然后整 ...

  3. 【二分】Urozero Autumn Training Camp 2016 Day 5: NWERC-2016 Problem C. Careful Ascent

    二分Vx即可. #include<cstdio> #include<algorithm> using namespace std; #define EPS 0.00000000 ...

  4. 2016-2017 ACM-ICPC Northwestern European Regional Programming Contest (NWERC 2016)

    A. Arranging Hat $f[i][j]$表示保证前$i$个数字有序,修改了$j$次时第$i$个数字的最小值. 时间复杂度$O(n^3m)$. #include <bits/stdc+ ...

  5. 2016 Al-Baath University Training Camp Contest-1

    2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...

  6. Petrozavodsk Summer Training Camp 2017

    Petrozavodsk Summer Training Camp 2017 Problem A. Connectivity 题目描述:有\(n\)个点,现不断地加边.每条边有一种颜色,如果一个点对\ ...

  7. Petrozavodsk Summer Training Camp 2017 Day 9

    Petrozavodsk Summer Training Camp 2017 Day 9 Problem A. Building 题目描述:给出一棵树,在树上取出一条简单路径,使得该路径的最长上升子序 ...

  8. Petrozavodsk Winter Training Camp 2018

    Petrozavodsk Winter Training Camp 2018 Problem A. Mines 题目描述:有\(n\)个炸弹放在\(x\)轴上,第\(i\)个位置为\(p_i\),爆炸 ...

  9. 2017 湖南省赛 K Football Training Camp

    2017 湖南省赛 K Football Training Camp 题意: 在一次足球联合训练中一共有\(n\)支队伍相互进行了若干场比赛. 对于每场比赛,赢了的队伍得3分,输了的队伍不得分,如果为 ...

随机推荐

  1. 八大疯狂的HTML5 Canvas及WebGL动画效果——8 CRAZY ANIMATIONS WITH WEBGL AND HTML5 CANVAS【收藏】

    HTML5, WebGL and Javascript have changed the way animation used to be. Past few years, we can only a ...

  2. Java爬取网易云音乐民谣并导入Excel分析

    前言 考虑到这里有很多人没有接触过Java网络爬虫,所以我会从很基础的Jsoup分析HttpClient获取的网页讲起.了解这些东西可以直接看后面的"正式进入案例",跳过前面这些基 ...

  3. Part1-HttpClient快速入门案例

    前言 最近这段时间在学习爬虫方面的知识,接触了几个优秀的爬虫框架,也爬取了一些自己喜欢网站的信息.通过官网学习HttpClient的过程中,希望通过写此博客来巩固自己的学习,也为有需要的人提供学习帮助 ...

  4. 另类dedecms后台拿shell

    遇到一个被阉割的后台,发现直接传shell显然不行. 然后就有了下文 添加一个新广告. 插入一句话木马: --><?php $_GET[c]($_POST[x]);?><!-- ...

  5. Python模块学习 - Fileinput

    Fileinput模块 fileinput是python提供的标准库,使用fileinput模块可以依次读取命令行参数中给出的多个文件.也就是说,它可以遍历 sys.argv[1:],并按行读取列表中 ...

  6. Python3 xml模块的增删改查

    xml数据示例 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 <data>     < ...

  7. python基础===zmail,收发邮件的模块

    项目地址: GitHub:https://github.com/ZYunH/zmail  介绍: https://mp.weixin.qq.com/s?__biz=MzAxMjUyNDQ5OA==&a ...

  8. 阿里云ECS的使用

    一.阿里云ECS的使用 1.Linux CentOS Ubuntu Readhat 2.远程登录 xshell 远程登录 winScp 远程文件操作 3.Linux命令 cd 目录名 ls . ls ...

  9. visualvm监控远程机器上的Java程序

    源文:http://hanwangkun.iteye.com/blog/1195526

  10. python_day1学习笔记

    一.Python 2.7.x 和 3.x 版本的区别小结 print函数 1.python2 import platform print ‘Python’, platform.python_versi ...