HDU 6300 Triangle Partition 思维

/**
C Triangle Partition
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6300

题意:给出3*n个点 构造出n个不相交的三角形 并且输出他们的编号
签到题 不相交 无限取出最相邻的三个点即可 排序即可实现;

*/

#include<bits/stdc++.h>
#define ll long long 
using namespace std;

const int maxn=1e4+7;
struct node {
	int x,y,id;
	bool  operator <(const node &a)const {
		if(x==a.x) return y<a.y;
		return x<a.x;
	}
}a[maxn];

int main (){
	int t;scanf("%d",&t);
	while(t--){
		int n;scanf("%d",&n);
		for(int i=1;i<=3*n;i++) scanf("%d %d",&a[i].x,&a[i].y),a[i].id=i;
		sort(a+1,a+1+3*n);
	    for(int i=1;i<=3*n;i+=3) printf("%d %d %d\n",a[i].id,a[i+1].id,a[i+2].id);
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/hypHuangYanPing/article/details/81783100