#include<bits/stdc++.h>
using namespace std;
struct Node{
public :
int x,y,z;
double rad;
bool operator < (const Node& rhs) const {
return rad < rhs.rad;
}
}c[1000],d[1000];
bool Turn(Node&a,Node&b)
{
return a.x*b.y>=a.y*b.x;
}
int main()
{
int N;
while(~scanf("%d",&N)&&N){
for(int i=0;i<N;i++) scanf("%d%d%d",&c[i].x,&c[i].y,&c[i].z);
if(N<=2) { printf("%d\n",N); continue; }
int maxn=0;
for(int i=0;i<N;i++){
int k=0;
for(int j=0;j<N;j++){
if(i!=j){
d[k].x = c[j].x-c[i].x;
d[k].y = c[j].y-c[i].y;
if(c[j].z){
d[k].x = -d[k].x;
d[k].y = -d[k].y;
}
d[k].rad = atan2(d[k].y,d[k].x);
k++;
}
}
sort(d,d+k);
int L=0;int ans=1;int R=0;
while(L<k){
if(L==R){
R=(R+1)%k; ans++;
}
while(L!=R&&Turn(d[L],d[R])){
ans++; R=(R+1)%k;
}
maxn = max(maxn,ans); L++; ans--;
}
}
printf("%d\n",maxn);
}
return 0;
}
[极角排序 扫描法]UVa1606 - Amphiphilic Carbon Molecules
最新推荐文章于 2020-02-17 22:47:47 发布