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

于是预处理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. node遇到的一些坑,npm无反应,cordova安装以后显示不是内部或外部命令

    1.输入npm -v 以后一直无反应 C:\Users\用户名 目录下找到 .npmrc文件,删除以后,执行npm -v顺利显示版本号 2.安装cordova以后一直报错,不是内部或外部命令也不是可运 ...

  2. mac系统中实现vitualBox中访问内网端口

    第一步,增加外网网段 打开vitualbox后,按管理菜单,点击->主机网络管理器,如图1所示.点击创建,创建下个网络主机. 图1 然后,关掉虚拟机,虚拟机的设置中,找到网络选项卡,然后点击网络 ...

  3. CSS3新属性解释及用法

    一. transition(a标签hover渐隐效果) a:hover{transition: color 0.15s linear 0s, background-color 0.3s linear ...

  4. html添加新元素兼容和访问

    <!DOCTYPE html> <html> <head> <title>Creating an HTML Element</title> ...

  5. Java之CyclicBarrier使用

    http://blog.csdn.net/shihuacai/article/details/8856407 1.类说明: 一个同步辅助类,它允许一组线程互相等待,直到到达某个公共屏障点 (commo ...

  6. MapReduce案例一:天气温度

    1.需求 2.思路 3.代码实现 3.1MyWeather 类代码: 这个类主要是用来定义hadoop的配置,在执行计算程序时所需加载的一些类. package com.hadoop.mr.weath ...

  7. Combination Sum I&&II(经典的回溯算法题)

    I: Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C w ...

  8. [转载] 更改pip源至国内镜像,显著提升下载速度

    原文地址: https://blog.csdn.net/lambert310/article/details/52412059 经常在使用python的时候需要安装各种模块,而pip是很强大的模块安装 ...

  9. python Mixin 是个啥?

    内容待添加... 参考文章: [1][python] Mixin 扫盲班

  10. css - 字体图标的制作

    很多的时候我们在开发过程中一般都是直接使用图片,尤其在移动页面频繁请求图片对性能不是很好 ,所以图标字体的应用也越来越广泛.一般情况下直接用的是font awesome字体,但是有时候需要制作自己风格 ...