uva1606

题目链接

#include<bits/stdc++.h>
using namespace std;
#define n 1010
struct point{
    int x, y;
    double rad;
    bool operator < (point b){
        return rad < b.rad;
    }

}points[n], p[n];

int m, color[n];

//判断是否符合条件。 bool left(point a, point b){ return a.x*b.y - a.y*b.x >= 0; } int solve(){ int ans = 0; for(int i = 0; i < m; i++){ int k = 0; for(int j = 0; j < m; j++){ if(j != i){ p[k].x = points[j].x - points[i].x; p[k].y = points[j].y - points[i].y; if(color[j]){ p[k].x = -p[k].x, p[k].y = -p[k].y; }
//计算角度。 p[k].rad = atan2(p[k].y, p[k].x); k++; } } //逆时针排序。 sort(p, p+k); int l = 0, r = 0; int cnt = 2; while(l < k){ if(l==r) {r = (r+1)%k; cnt++; } while(l != r && left(p[l], p[r])) {r = (r+1)%k, cnt++; } cnt--; l++; ans = max(ans, cnt); } } return ans; } int main() { while(cin >> m && m){ for(int i = 0; i < m; i++) cin >> points[i].x >> points[i].y >> color[i]; cout << solve() << endl; } }

  

posted @ 2020-09-16 21:35  jvruodejxt  阅读(118)  评论(0编辑  收藏  举报

Contact with me