Submission #3664

#TimeUsernameProblemLanguageResultExecution timeMemory
3664eldkqmfhf123Divide into triangle (kriii1_D)C++98
1 / 1
0 ms1684 KiB
#include<iostream> #include<math.h> #include<algorithm> using namespace std; struct queue { int x, y, index; bool operator()(queue a, queue b) { if(a.x < b.x)return 1; if(a.x == b.x && a.y < b.y)return 1; return 0; } }list[901]; int main() { int n; cin >> n; n*=3; int i,j; for(i=0;i<n;i++) { cin >> list[i].x >> list[i].y; list[i].index = i+1; } std::sort(list,list+n,queue()); int visit[901]={0,}; for(int t=0;t<n/3;t++) { int ans=0; for(i=0;i<n;i++) { if(visit[i])continue; for(j=i+1;j<n;j++) { if(visit[j])continue; for(int k=j+1;k<n;k++) { if(visit[k])continue; cout << list[i].index << " " << list[j].index << " " << list[k].index << endl; visit[i]=1; visit[j]=1; visit[k]=1; ans=1; break; } if(ans)break; } if(ans)break; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...