感觉就是计算几何的模拟
感谢LUKE和A神的思路
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<map>
#define pi acos(-1.0)
#define eps 1e-8
#define ll long long
#define L 10050
#define N 1050
#define Mod 1000000007
#define M 99999999999
#define clr(a) memset(a,0,sizeof(a))
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template<class T>
inline bool read(T &n)
{
T x = 0, tmp = 1;
char c = getchar();
while((c < '0' || c > '9') && c != '-' && c != EOF) c = getchar();
if(c == EOF) return false;
if(c == '-') c = getchar(), tmp = -1;
while(c >= '0' && c <= '9') x *= 10, x += (c - '0'),c = getchar();
n = x*tmp;
return true;
}
template <class T>
inline void write(T n)
{
if(n < 0)
{
putchar('-');
n = -n;
}
int len = 0,data[20];
while(n)
{
data[len++] = n%10;
n /= 10;
}
if(!len) data[len++] = 0;
while(len--) putchar(data[len]+48);
}
struct point
{
double x,y,c;
int id;
}p[1001],q[1001],pq[1001];
bool mult(point sp, point ep, point op){
if ( (sp.x - op.x) * (ep.y - op.y) > (ep.x - op.x) * (sp.y - op.y) ) return true;
if (sp.x==ep.x && sp.y==ep.y) return true;
return false;
}
bool operator < (const point &l, const point &r){
return l.y < r.y || (l.y == r.y && l.x < r.x);
}
int graham(point pnt[], int n, point res[]){
int i, len, k = 0, top = 1;
sort(pnt, pnt+n);
if(n == 0) return 0; res[0] = pnt[0];
if(n == 1) return 1; res[1] = pnt[1];
if(n == 2) return 2; res[2] = pnt[2];
for(i = 2; i < n; i++) {
while(top && mult(pnt[i], res[top], res[top-1]))
top--;
res[++top] = pnt[i];
}
len = top; res[++top] = pnt[n - 2];
for(i = n - 3; i >= 0; i--) {
while(top!=len && mult(pnt[i], res[top], res[top-1])) top--;
res[++top] = pnt[i];
}
return top; // 返回凸包中点的个数
}
int main(){
int i,j,k,n,x;
int cas=1;
int a[L],res;
int sig[L],Max=0;
int rtt[1001];
//ios::sync_with_stdio(false);
while(read(n)&&n){
Max=0;
memset(p,0,sizeof p);
memset(q,0,sizeof q);
memset(pq,0,sizeof pq);
for(i=0;i<n;i++){
read(p[i].x);
read(p[i].y);
read(p[i].c);
p[i].id=i;
if(p[i].c>Max)Max=p[i].c;
}
int cnt=0;
for(i=0;i<n;i++){
if(p[i].c==Max && Max!=0){
pq[cnt++]=p[i];
}
}
// for(i=0;i<cnt;i++)
// printf("POINT:X %lf Y%lf\n",pq[i].x,pq[i].y);
int ppq=graham(pq,cnt,q);
memset(rtt,0,sizeof rtt);
// printf("PPQ%d\n",ppq);
// for(i=0;i<ppq;i++)
// printf("POINT:X %lf Y%lf\n",q[i].x,q[i].y);
printf("Case #%d: ",cas++);
for(i=0;i<ppq;i++){
rtt[q[i].id]=1;
}
for(i=0;i<ppq;i++){
for(j=0;j<cnt;j++){
if(q[i].x==pq[j].x&&q[i].y==pq[j].y&&q[i].id!=pq[j].id){
rtt[q[i].id]=0;
rtt[pq[j].id]=0;
}
}
}
for(i=0;i<n;i++)
printf("%d",rtt[i]);
printf("\n");
}
return 0;
}