Submission #3923

#TimeUsernameProblemLanguageResultExecution timeMemory
3923hyeonjae0310Divide into triangle (kriii1_D)C++98
0 / 1
0 ms1680 KiB
#include <iostream> #include <algorithm> #include <cmath> using namespace std; typedef struct point{ int x; int y; int idx; } point; point a[300]; int compare(point p1, point p2) { if(p1.x==p2.x) return (p1.y<p2.y); else return (p1.x<p2.x); } int ccw(point A, point B, point C) { return (A.x * B.y + B.x * C.y + C.x * A.y) - (A.x * C.y + B.x * A.y + C.x * B.y); } bool compare2(point p1, point p2) { if(0<ccw(a[0],p1,p2)) return true; else return false; } int main() { int n,i; cin>>n; n=n*3; for(i=0;i<n;i++) { cin>>a[i].x>>a[i].y; a[i].idx=i+1; } for(i=0;i<n;i+=3) { sort(a+i,a+n,compare); sort(a+1+i,a+n,compare2); cout<<a[i].idx<<' '<<a[i+1].idx<<' '<<a[i+2].idx<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...