LA 6263 The Dragon and the knights 平面划分 ,欧拉定理
来源:互联网 发布:maxdos网络克隆工具 编辑:程序博客网 时间:2024/06/08 15:09
题目地址:LA6263
首先对于直线将平面划分为多少个区域,有平面上的欧拉定理。
F=E-V+1 (不是2)
然后统计每一对相交的直线(因为没有三点共线) ,对E+=2,V++;
关键的是判断每一个点关于直线的方位“标示符”,这里是一个长度为n的二进制数,n<=100 ,用两个long long 存储就好了 如果用vector存贮会超时(比较时),
然后取unique,得到点分布的区域数,和欧拉定理得到的区域数进行比较就行了。
注意:超int 要用long long。
代码:
#include<iostream>#include<cmath>#include<cstdio>#include<algorithm>#include<vector>using namespace std;const double eps=1e-8;struct Point{ long long x; long long y; Point(long long x=0, long long y=0) :x(x),y(y) {} };typedef Point Vector;Point p[50005];Point inter[10000];long long a[105],b[105],c[105];int n,m;//vector<int> v[50005];bool vector_cmp(vector<int> a,vector<int> b){ int sz=a.size(); for(int i=0;i<sz;i++) { if(a[i]<b[i]) return 1; else if(a[i]>b[i]) return 0; } return 0; }int getBit(long long a,long long b,long long c,Point p){ if(a*p.x+b*p.y+c>0) return 1; else return 0;}struct status{ long long a; long long b; status(long long a=0,long long b=0):a(a),b(b){} };status s[50005];bool status_cmp(status A,status B){ if(A.a<B.a) return 1; else if(A.a==B.a) { if(A.b<B.b) return 1; else return 0; } else return 0;}bool operator==(status A,status B){ if(A.a==B.a&&A.b==B.b) return 1; else return 0; }long long Cross(Vector A,Vector B){ return A.x*B.y-A.y*B.x; }int main(){ int T; cin>>T; while(T--) { cin>>n>>m; for(int i=0;i<n;i++) { scanf("%lld%lld%lld",&a[i],&b[i],&c[i]); } for(int i=0;i<m;i++) { scanf("%lld%lld",&p[i].x,&p[i].y); } // for(int i=0;i<m;i++)// {// for(int j=0;j<n;j++)// {// v[i].push_back(getBit(a[j], b[j], c[j], p[i]));// // }// } for(int i=0;i<m;i++) { s[i].a=0; s[i].b=0; if(n<=50) for(int j=0;j<n;j++) { s[i].a=2*s[i].a+getBit(a[j], b[j], c[j], p[i]); } else { for(int j=0;j<50;j++) { s[i].a=2*s[i].a+getBit(a[j], b[j], c[j], p[i]); } for(int j=50;j<n;j++) { s[i].b=2*s[i].b+getBit(a[j], b[j], c[j], p[i]); } } } sort(s,s+m,status_cmp); long long protected_region =unique(s,s+m)-s;// sort(v,v+m,vector_cmp);// // int protected_region =unique(v,v+m)-v; long long V=0,F=0,E=n; int cnt=0; for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { if(Cross(Vector(a[i],b[i]), Vector(a[j],b[j]))!=0) { E+=2; V++; } } } F=E-V+1; // cout<<F<<' '<<protected_region<<endl; if(F==protected_region) cout<<"PROTECTED"<<endl; else cout<<"VULNERABLE"<<endl; } }
0 0
- LA 6263 The Dragon and the knights 平面划分 ,欧拉定理
- The Dragon and the knights
- 【bzoj4064】[Cerc2012]The Dragon and the knights
- LA 3218 - Find the Border PSLG 平面直线区域划分
- LA 3523 - Knights of the Round Table
- LA 3263 欧拉定理
- LA 3263 (欧拉定理)
- LA-3263-计算几何,欧拉定理
- Dividing The Plane 直线划分平面
- The Dragon Boat Festival and Rice dumpling
- 【POJ3696】The Luckiest Number-欧拉定理+快速幂
- LA 3523 Knights of the Round Table(点双连通分量+二分图判断)
- LA 3523 Knights of the Round Table 边双连通分量+二分图判定
- LA 3263 - That Nice Euler Circuit 欧拉定理
- LA 3236 That Nice Euler Circuit(欧拉定理)
- LA 3263 That Nice Euler Circuit 欧拉定理 -
- 【hdu2462】【数论】【欧拉函数+欧拉定理+大数快速幂】The Luckiest number
- The Dragon of Loowater
- java解惑之多重类型
- Android 长按电源键关机整个流程小学习
- 配置 Nginx SSL 避免不够安全的加密算法
- Android 通过solid来定义不同边框的颜色,可以只定义一个边框的颜色
- Oracle ORA-01034,ORA-27101,ORA-00600
- LA 6263 The Dragon and the knights 平面划分 ,欧拉定理
- cuda——使用多个stream
- Effective OC 2.0读书笔记 第7条:在对象内部尽量直接访问实例变量
- android 给apk文件签名
- 关于VB.NET项目打包后数据库无法写入数据的解决方案
- 利用PHPExcel转Excel饼图
- c++中new和delete的使用方法
- 五一成都峨眉山三日游 20140501~20140503
- terminal的常用快捷键