题目:https://vjudge.net/problem/UVA-1606
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<set>
#include<queue>
#include<cmath>
#pragma warning(disable:4996)
using namespace std;
const int maxn = 1000 + 5;
int n;
struct Point {
int x, y,color;
double angle;
bool operator < (const Point& rhs) const
{
return angle < rhs.angle;
}
void input()
{
cin >> x >> y >> color;
}
};
Point s[maxn],v[maxn];
bool det(const Point a, const Point b)
{
return a.x*b.y - a.y*b.x >= 0;
}
int solve()
{
if (n <= 2) return 2;
int ans = 0;
for (int i = 0; i < n; i++)
{
int k = 0;
for (int j = 0; j < n; j++)
{
if (j != i)
{
v[k].x = s[j].x - s[i].x;
v[k].y = s[j].y - s[i].y;
if (s[j].color)
{
v[k].x = -v[k].x;
v[k].y = -v[k].y;
}
v[k].angle = atan2(v[k].y, v[k].x);
k++;
}
}
sort(v, v + k);
int L = 0, R = 0, cnt = 2;
while (L < k) {
if (R == L) { R = (R + 1) % k; cnt = 2; }
while (R != L && det(v[L], v[R])) { R = (R + 1) % k; cnt++; }
ans = max(ans, cnt);
cnt--;
L++;
}
}
return ans;
}
int main()
{
while (cin >> n &&n)
{
for (int i = 0; i < n; i++)
scanf("%d%d%d", &s[i].x, &s[i].y, &s[i].color);
cout << solve() << endl;
}
return 0;
}