0开始出现一次,结尾出现一次。
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef int lint;
const int maxn = 2001;
const double eps = 1e-12;
const double PI = acos(-1.0);
int sgn(double x)
{
if(fabs(x) < eps)return 0;
if(x < 0)return -1;
else return 1;
}
struct Point
{
double x,y;
Point(){}
Point(double _x,double _y)
{ x = _x;y = _y;
}
Point operator -(const Point &b)const
{
return Point(x - b.x,y - b.y);
}
//叉积
double operator ^(const Point &b)const
{
return x*b.y - y*b.x; }
//点积
double operator *(const Point &b)const
{
return x*b.x + y*b.y; }
};
Point lis[maxn];
int Stack[maxn],top;
bool _cmp(Point p1,Point p2)
{
if( !sgn( p1.x-p2.x ) ) return p1.y < p2.y;
return p1.x < p2.x;
}
lint in_st[maxn];
void Graham(int n)
{
for( lint i = 0;i < n;i++ ) in_st[i] = 0;
sort(lis,lis+n,_cmp);
top = 0;
for(int i = 0;i < n;i++)
{
while(top > 1 &&sgn((lis[Stack[top-1]]-lis[Stack[top-2]])^(lis[i]-lis[Stack[top-2]])) <0) {
top--;in_st[Stack[top]] = 0;
}
Stack[top++] = i;
in_st[i] = 1;
}
int k = top;
for( int i = n-2;i >= 0;i-- ){
if(in_st[i]&&i) continue;
while( top > k && sgn((lis[Stack[top-1]]-lis[Stack[top-2]])^(lis[i]-lis[Stack[top-2]])) <0 ){
top--; in_st[Stack[top]] = 0;
}
Stack[ top++ ] = i;
in_st[i] = 1;
}
//top--;
}
struct point{
lint id;
double x,y,v;
point( lint _id = 0,double _x = 0,double _y = 0,double _v = 0 ){
x=_x;y=_y;id=_id;v = _v;
}
bool operator < ( const point& b )const{
if( x == b.x ) return y < b.y;
return x < b.x;
}
}p[maxn],p2[maxn];
lint vis[maxn],id[maxn],ans[maxn];
int main(){
lint n,ca = 0;
while( 1 == scanf("%d",&n) && n ) {
printf("Case #%d: ",++ca);
double ma = 0;
memset( ans,0,sizeof( ans ) );
memset( vis,0,sizeof(vis) );
for (lint i = 1; i <= n; i++) {
scanf("%lf%lf%lf", &p[i].x, &p[i].y, &p[i].v);
p[i].id = i; ma = max( ma,p[i].v );
}
if( !sgn( ma ) ){
for( lint i = 1;i <= n;i++ ){
printf("0");
}
printf("\n");
continue;
}
lint tot = 0;
for( lint i = 1;i <= n;i++ ){
if( !sgn( p[i].v-ma ) ) p2[tot++] = p[i];
}
sort( p2,p2+tot );
lint tot2 = 0;
for( lint i = 0;i < tot;i++ ){
lis[tot2++] = Point(p2[i].x,p2[i].y);
id[tot2-1] = p2[i].id;
while( i+1 < tot && !sgn( p2[i].x-p2[i+1].x ) && !sgn( p2[i].y-p2[i+1].y ) ) {
vis[ p2[i].id ] = vis[ p2[i+1].id ] = 1;
i++;
}
}
Graham(tot2);
for( lint i = 0;i < top;i++ ){
//if(vis[i]) continue;
ans[ id[ Stack[i] ] ] = 1;
}
for( lint i = 1;i <= n;i++ ){
if(vis[i]) printf("0");
else printf("%d",ans[i]);
}
printf("\n");
}
return 0;
}