hdu-4946 Area of Mushroom 凸包
来源:互联网 发布:三层网络ping 请求超时 编辑:程序博客网 时间:2024/04/30 05:25
题目链接
#include <stdio.h>#include <string.h>#include <iostream>#include <queue>#include <vector>#include <math.h>#include <algorithm>using namespace std;typedef __int64 LL;const int maxn = 1005;const int Mod = 1000000007;int n,N;int ans[maxn];int mark[maxn];struct Point { double x,y,p; int id; Point( double x = 0,double y = 0 ): x(x),y(y) { } }point[maxn],ch[maxn]; typedef Point Vector; bool cmp( Point A,Point B ) { //return A.x < B.x || ( A.x == B.x && A.y < B.y ); if( A.x == B.x ) return A.y < B.y; return A.x < B.x; } double Cross( Vector A,Vector B ) { return A.x * B.y - A.y * B.x; } Vector operator - ( Vector A,Vector B ) { return Vector( A.x - B.x,A.y - B.y ); } int ConvexHull() { sort( point,point+n,cmp ); memset( mark,0,sizeof(mark) ); for( int i = 1; i < n; i ++ ) { if( point[i].x == point[i-1].x && point[i].y == point[i-1].y ){ mark[point[i].id] = 1; mark[point[i-1].id] = 2; } } int m = 0; for( int i = 0; i < n; i ++ ) { if( mark[point[i].id] == 2 ) continue; while( m > 1 && Cross( ch[m-1]-ch[m-2],point[i]-ch[m-2] ) < 0 ) m --; ch[m++] = point[i]; } int k = m; for( int i = n-2; i >= 0; i -- ) { if( mark[point[i].id] == 2 ) continue; while( m > k && Cross( ch[m-1]-ch[m-2],point[i]-ch[m-2] ) < 0 ) m --; ch[m++] = point[i]; } if( n > 1 ) m --; return m; } bool cmp1( Point a,Point b ){ return a.p > b.p;}int main(){ #ifndef ONLINE_JUDGE freopen("data.txt","r",stdin); #endif int c = 1; while( scanf("%d",&N) != EOF,N ) { int flag = 1; memset( ans,0,sizeof(ans) ); for( int i = 0; i < N; i ++ ) { scanf("%lf%lf%lf",&point[i].x,&point[i].y,&point[i].p); point[i].id = i; } sort( point,point+N,cmp1 ); if( point[0].p != 0 ) { n = N; for( int i = 1; i < N; i ++ ) { if( point[i].p != point[i-1].p ) { n = i; break; } } int m = ConvexHull(); for( int i = 0; i < m; i ++ ) if( !mark[ch[i].id] ) ans[ch[i].id] = 1; } printf("Case #%d: ",c ++); for( int i = 0; i < N; i ++ ) printf("%d",ans[i]); puts(""); } return 0;}
0 0
- HDU 4946 Area of Mushroom 凸包
- HDU 4946 Area of Mushroom 凸包
- hdu-4946 Area of Mushroom 凸包
- 【凸包】HDU 4946 Area of Mushroom
- HDU 4946 Area of Mushroom(凸包)
- hdu 4946 Area of Mushroom(凸包)
- 【HDU】4946 Area of Mushroom 凸包
- HDU 4946 Area of Mushroom (凸包)
- hdu 4946 Area of Mushroom 凸包
- Hdu 1946 Area of Mushroom[凸包]
- HDU 4946 Area of Mushroom 凸包 第八次多校
- HDU 4946 Area of Mushroom 共线凸包
- hdu 4946 Area of Mushroom 计算几何(凸包)
- HDU 4946 Area of Mushroom(凸包)
- HDU 4946 Area of Mushroom(共线凸包)
- HDU 4946 Area of Mushroom (凸包)
- HDU 4946 - Area of Mushroom (计算几何 凸包)
- HDU 4946 Area of Mushroom (凸包 思维)
- error:无法复制xx:访问被拒绝 请确定磁盘未满或未被写保护 而且文件未被使用
- Android事件处理之多点触摸与手势识别
- 将一个数组中的元素利用另一个数组中的元素进行拆分
- phpMailer 发邮件例子、乱码、发送html内容介绍
- 相机和相册的调用
- hdu-4946 Area of Mushroom 凸包
- C语言字符串操作--删除子串
- 【 D3.js 入门系列 --- 9.5 】 树状图的制作
- 12个方法去创造你人生中的第二次机会
- Binary Tree Traversals hdu 1710 c++
- uva 11971 - Polygon(连续概率问题)
- ss
- 2014 Multi-University Training Contest 8 题解——by xudyh
- 拼接字符串2