Problem Description Chiaki has 3n points p1,p2,…,p3n . It is guaranteed that no three points are collinear.
Input There are multiple test cases. The first line of input contains an integer T , indicating the number of test cases. For each test case:
Output For each test case, output n lines contain three integers ai,bi,ci (1≤ai,bi,ci≤3n ) each denoting the indices of points the i -th triangle use. If there are multiple solutions, you can output any of them.
Sample Input 1 1 1 2 2 3 3 5
Sample Output 1 2 3
Source |
因为不可能三点共线,所以直接排序输出
#include <bits/stdc++.h>
using namespace std;
struct haha{
int x,y;
int s;
}we[300000];
bool cmp(haha a,haha b){
if(a.x==b.x) return a.y<b.y;
return a.x<b.x;
}
int main(){
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
n=n*3;
for(int i=0;i<n;i++){
scanf("%d %d",&we[i].x,&we[i].y);
we[i].s=i;
}
sort(we,we+n,cmp);
for(int i=0;i<=n-3;i+=3){
printf("%d %d %d\n",we[i].s+1,we[i+1].s+1,we[i+2].s+1);
}
}
}