# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3923 | hyeonjae0310 | Divide into triangle (kriii1_D) | C++98 | 0 ms | 1680 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |