Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others)
Total Submission(s): 1107    Accepted Submission(s): 556
Special Judge


Problem Description
Chiaki has n points.
 

 

Input
There are multiple test cases. The first line of input contains an integer 10000.
 

 

Output
For each test case, output 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
 
 
按x排下序就可以了,然后按次序输出三个
 1 #include <iostream>
 2 #include <cstring>
 3 #include <algorithm>
 4 #define N 3005
 5 using namespace std;
 6 struct Node{
 7     int x,y;
 8     int in;
 9 }node[N];
10 
11 bool cmp(Node a,Node b){
12     if(a.x == b.x){
13         return a.y<b.y;
14     }
15     return a.x<b.x;
16 }
17 
18 int main(){
19     int t;
20     while(cin>>t){
21         while(t--){
22             memset(node,0,sizeof(node));
23             int n;
24             cin>>n;
25             for(int i=0;i<3*n;i++){
26                 cin>>node[i].x>>node[i].y;
27                 node[i].in = i+1;
28             }
29             sort(node,node+3*n,cmp);
30             for(int i=0;i<3*n;i=i+3){
31                 cout<<node[i].in<<" "<<node[i+1].in<<" "<<node[i+2].in<<endl;
32             }
33         }
34     }
35     return 0;
36 }

 

相关文章:

  • 2022-12-23
  • 2021-05-17
  • 2021-10-14
  • 2021-09-10
  • 2021-10-09
  • 2021-10-02
猜你喜欢
  • 2021-10-28
  • 2022-12-23
  • 2021-10-08
  • 2021-07-23
相关资源
相似解决方案