hdu6300按极角排序

#include <bits/stdc++.h>
#define fir first
#define se second
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
const int maxn = 1e5 + 10;
const int maxm = 1e6 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const double eps = 1e-7;
int n;
struct Point {
    double x, y, angle;
    int id;
}p[maxn];
int cmp(Point a, Point b) {
    return a.angle<b.angle;
}
int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        scanf("%d", &n);
        for (int i = 1; i <= 3 * n; i++) {
            scanf("%lf %lf", &p[i].x, &p[i].y);
            p[i].id = i;
            p[i].angle = atan2(p[i].y, p[i].x);
        }
        sort(p + 1, p + 3 * n + 1, cmp);
        for (int i = 1; i <= 3 * n; i += 3) {
            printf("%d %d %d\n", p[i].id, p[i + 1].id, p[i + 2].id);
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_37765455/article/details/81185640