标签:des style blog http color java os io
如果一个人能统治无穷远处,那么他的速度一定是最大的。除了那几种很坑的数据,比如同一个点速度相同的两个人。永远都是不可能。所以你要处理出来所有速度最大的点,然后用他们构成一个凸包,你把端点的点求出来了,还得判断一下在边上的情况。然后顶点和在边上的点所构成的就是可以到达无穷远处的人。
PS:抄了芳姐的模版。。哈哈哈
3 0 0 3 1 1 2 2 2 1 0
Case #1: 100
#include <algorithm> #include <iostream> #include <stdlib.h> #include <string.h> #include <iomanip> #include <stdio.h> #include <string> #include <queue> #include <cmath> #include <stack> #include <ctime> #include <map> #include <set> #define eps 1e-9 ///#define M 1000100 #define LL __int64 ///#define LL long long ///#define INF 0x7ffffff #define INF 0x3f3f3f3f #define PI 3.1415926535898 #define zero(x) ((fabs(x)<eps)?0:x) #define clearall(A, X) memset(A, X, sizeof(A)) using namespace std; const int maxn = 2010; struct point { int x,y; int v,id; point(int x = 0,int y = 0):x(x),y(y) {} } p[maxn],ch[maxn],q[maxn],pq[maxn]; int f[maxn]; typedef point pointt; point operator -(point a,point b) { return point(a.x-b.x,a.y-b.y); } int dcmp(double x) { if(fabs(x)<eps) return 0; return x<0?-1:1; } int cross(point a,point b) { return a.x*b.y-a.y*b.x; } int mul(point a,point b,point c) { return cross(b-a,c-a); } double dis(point a) { return sqrt(a.x*a.x+a.y*a.y); } bool cmp(point a,point b) { if(mul(p[0],a,b)==0) return dis(a-p[0])<dis(b-p[0]); return mul(p[0],a,b)>0; } int graham(int n)///返回点的个数 { int i,k =0 ,top; if(n<2) return 0; point tmp ; for(i = 0; i < n ; i++) { if(dcmp(p[i].y-p[k].y)<0||(dcmp(p[i].y-p[k].y)==0&&dcmp(p[i].x-p[k].x)<0)) k = i; } swap(p[k],p[0]); sort(p+1,p+n,cmp); ch[0] = p[0]; ch[1] = p[1]; top = 1; for(i = 2; i < n ; i++) { while(top>0&&dcmp(mul(ch[top-1],ch[top],p[i]))<=0) top--; top++; ch[top] = p[i]; } return top; } bool cmpp(point a,point b) { if(a.x==b.x) return a.y<b.y; return a.x<b.x; } int main() { int Case = 1; int n; while(cin >>n) { if(!n) break; memset(f, 0, sizeof(f)); int Max = -INF; for(int i = 1; i <= n; i++) { scanf("%d %d %d",&q[i].x, &q[i].y, &q[i].v); q[i].id = i; if(!q[i].v) f[i] = -2; Max = max(Max, q[i].v); } for(int i = 1; i <= n; i++) { if(q[i].v != Max) continue; for(int j = i+1; j <= n; j++) { if(q[j].x == q[i].x && q[j].y == q[i].y && q[j].v == q[i].v) { f[q[j].id] = -1; f[q[i].id] = -1; } } } int t = 0; for(int i = 1; i <= n; i++) if(q[i].v == Max && f[q[i].id] != -2) p[t++] = q[i]; int m = graham(t); cout<<"Case #"<<Case++<<": "; if(m < 2) { for(int i = 1; i <= n; i++) { if(f[i] != -1 && f[i] != -2 && q[i].v == Max) cout<<1; else cout<<0; } cout<<endl; continue; } ch[m+1] = ch[0]; for(int i = 0; i <= m; i++) if(!f[ch[i].id]) f[ch[i].id] = 1; for(int i = 1; i <= n; i++) { if(f[i] || q[i].v != Max) continue; for(int j = 0; j <= m; j++) if(mul(ch[j], ch[j+1], q[i]) == 0) f[i] = 1; } for(int i = 1; i <= n; i++) { if(f[i] == 1) cout<<1; else cout<<0; } cout<<endl; } return 0; }
HDU 4946 Area of Mushroom(凸包),布布扣,bubuko.com
标签:des style blog http color java os io
原文地址:http://blog.csdn.net/xu12110501127/article/details/38563603