省选前练模板系列;

#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=;
const double eps=1e-,inf=1e9;
int n1,n2,m1,m2,pp;
double mi;
int dcmp(double x){if(fabs(x)<eps)return ;return x<?-:;}
struct vec{
double x,y,ang;
vec(){};
vec(double a,double b){x=a,y=b;}
vec operator-(vec a){return vec(x-a.x,y-a.y);}
vec operator+(vec a){return vec(x+a.x,y+a.y);}
bool operator<(const vec&a)const{
return dcmp(x-a.x)<||(dcmp(x-a.x)==&&y<a.y);
}
}p1[maxn],p2[maxn],ch1[maxn],ch2[maxn],p0,t1,t2,t3;
double cross(vec a,vec b){return a.x*b.y-b.x*a.y;}
double dot(vec a,vec b){return a.x*b.x+a.y*b.y;}
bool onli(vec p,vec a1,vec a2){
if(p.x=a1.x&&p.y==a1.y)return ;
if(p.x=a2.x&&p.y==a2.y)return ;
return dcmp(cross(a1-p,a2-p))==&&dcmp(dot(a1-p,a2-p))<;
}
bool jiao(vec a1,vec a2,vec b1,vec b2){
if(!(min(a1.x,a2.x)<=max(b1.x,b2.x)&&min(b1.y,b2.y)<=max(a1.y,a2.y)&&min(b1.x,b2.x)<=max(a1.x,a2.x)&&min(a1.y,a2.y)<=max(b1.y,b2.y)))
return ;
double c1=cross(a2-a1,b1-a1),c2=cross(a2-a1,b2-a1);
double c3=cross(b2-b1,a1-b1),c4=cross(b2-b1,a2-b1);
return dcmp(c1)*dcmp(c2)<=&&dcmp(c3)*dcmp(c4)<=;
}
bool inbao(vec p,vec* a,int n){
if(dcmp(cross(a[]-a[],p-a[]))<||dcmp(cross(a[n-]-a[],p-a[]))>)return ;
if(dcmp(cross(a[]-a[],p-a[]))==){
if(onli(p,a[],a[]))return ;
else return ;
}
if(dcmp(cross(a[n-]-a[],p-a[]))==){
if(onli(p,a[],a[n-]))return ;
else return ;
}
int l=,r=n-;
while(l<r){
int mid=l+r>>;
if(dcmp(cross(p-a[],a[mid]-a[]))>)r=mid;
else l=mid+;
}
//cout<<l<<endl;
if(cross(a[l]-a[l-],p-a[l-])>=)return ;
return ;
}
int build(vec *p,int n,vec *ch){
sort(p,p+n);
int m=;
for(int i=;i<n;++i){
while(m>&&cross(ch[m-]-ch[m-],p[i]-ch[m-])<=)m--;
ch[m++]=p[i];
}
int k=m;
for(int i=n-;i>=;--i){
while(m>k&&cross(ch[m-]-ch[m-],p[i]-ch[m-])<=)m--;
ch[m++]=p[i];
}
if(n>)m--;
return m;
}
void solve(){
for(int i=;i<n1;++i)scanf("%lf%lf",&p1[i].x,&p1[i].y);
for(int i=;i<n2;++i)scanf("%lf%lf",&p2[i].x,&p2[i].y);
if(n1==&&n2==){
if(p1[].x==p2[].x&&p1[].y==p2[].y){puts("No");return;}
else{puts("Yes");return;}
}
m1=build(p1,n1,ch1),m2=build(p2,n2,ch2);
if(m2>){
for(int i=;i<m1;++i)if(inbao(ch1[i],ch2,m2)){puts("No");return;}
}
if(m1>){
for(int i=;i<m2;++i)if(inbao(ch2[i],ch1,m1)){puts("No");return;}
}
for(int i=;i<m1;++i)
for(int j=;j<m2;++j)
if(jiao(ch1[i],ch1[(i+)%m1],ch2[j],ch2[(j+)%m2])){
puts("No");return;
}
puts("Yes");
}
int main(){
while(scanf("%d%d",&n1,&n2)!=EOF&&n1){
solve();
}
return ;
}
/*
4 3
100 600
200 400
600 500
300 700
400 100
600 200
500 300
4 3
100 600
400 100
600 200
500 300
200 400
600 500
300 700
0 0
*/

uva10256(计算几何)的更多相关文章

  1. 【题解】The Great Divide [Uva10256]

    [题解]The Great Divide [Uva10256] 传送门:\(\text{The Great Divide [Uva10256]}\) [题目描述] 输入多组数据,每组数据给定 \(n\ ...

  2. ACM/ICPC 之 计算几何入门-叉积-to left test(POJ2318-POJ2398)

    POJ2318 本题需要运用to left test不断判断点处于哪个分区,并统计分区的点个数(保证点不在边界和界外),用来做叉积入门题很合适 //计算几何-叉积入门题 //Time:157Ms Me ...

  3. HDU 2202 计算几何

    最大三角形 Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  4. ACM 计算几何中的精度问题(转)

    http://www.cnblogs.com/acsmile/archive/2011/05/09/2040918.html 计算几何头疼的地方一般在于代码量大和精度问题,代码量问题只要平时注意积累模 ...

  5. hdu 2393:Higher Math(计算几何,水题)

    Higher Math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  6. sdut 2603:Rescue The Princess(第四届山东省省赛原题,计算几何,向量旋转 + 向量交点)

    Rescue The Princess Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Several days ago, a b ...

  7. [知识点]计算几何I——基础知识与多边形面积

    // 此博文为迁移而来,写于2015年4月9日,不代表本人现在的观点与看法.原始地址:http://blog.sina.com.cn/s/blog_6022c4720102vxaq.html 1.前言 ...

  8. POJ 1106 Transmitters(计算几何)

    题目链接 切计算几何,感觉计算几何的算法还不熟.此题,枚举线段和圆点的直线,平分一个圆 #include <iostream> #include <cstring> #incl ...

  9. TYVJ计算几何

    今天讲了计算几何,发几道水水的tyvj上的题解... 计算几何好难啊!@Mrs.General....怎么办.... 这几道题都是在省选之前做的,所以前面的Point运算啊,dcmp啊,什么什么的,基 ...

随机推荐

  1. C#分割字符串并统计重复出现的次数

    static void Main(string[] args) { string ss = "12345678904682qwertyuioplkjhgfdsazxcvbnmmlpokuhy ...

  2. Game Engine Architecture 11

    [Game Engine Architecture 11] 1.three most-common techniques used in modern game engines. 1)Cel Anim ...

  3. JS工具类

    封装了开发中常用的操作 并添加了一些扩展方法供调用 var util = { //获取Url中的参数(不支持中文) getParams: function() { var url = location ...

  4. css: box-sizing

    border-box 宽度包含了边框 content-box 边框不包含在内容区中,会增加到实际的宽度中

  5. 我们一起踩过的坑----react(antd)(二)

    1.antd Upload默认值问题 需求是这样的,后台若没有图片默认值,则只有上传按钮,且只能上传一张图片:若有默认值,则显示默认头像图片, 可删除,删除之后有且只能添加一张图片,没有删除默认图片时 ...

  6. Python Selenium系列学习

    以下记录刚接触Python Selenium操作Web UI的学习问题: 1.python selenium三种等待方式: ①强制等待:time.sleep(value):设置等待最简单的方法就是强制 ...

  7. jQuery on() 方法 为选定已存在元素和未来元素绑定标准事件和自定义事件

    很有必要说说jQuery的on方法,这个方法存在大乾坤大奥秘,主要注意两点: 1.为已存在元素和未来元素(动态添加元素)绑定处理函数. 2.自定义一个非标准的事件并绑定处理函数. 定义和用法 on() ...

  8. 修改当前会话的sql_mode

    -- show variables like 'sql_mode'; -- set session sql_mode="ONLY_FULL_GROUP_BY,STRICT_TRANS_TAB ...

  9. 解决win系统无法安装.NET Framework 4.0 4.6 原因是HRESULT0xc8000222

    1.开始----- 运行------- cmd ----- 键入net stop WuAuServ回车(停止windows update服务) 2.开始----- 运行----键入%windir%回车 ...

  10. 记录一下maven使用过程中的问题

    Failed to execute goal on project bos_fore: Could not resolve dependencies for project 上面问题,我把<de ...