# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3879 | hyeonjae0310 | Divide into triangle (kriii1_D) | C++98 | 0 ms | 1240 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 <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef struct POINT
{
pair<long long, long long> point;
int index;
}POINT;
POINT STD;
long long CCW(pair<long long, long long> a, pair<long long, long long> b, pair<long long, long long> c)
{
return (a.first*b.second+b.first*c.second+c.first+a.second)-(a.second*b.first+b.second*c.first+c.second*a.first);
}
bool pair_compare(POINT a, POINT b)
{
if(a.point.first != b.point.first)
{
return (a.point.first < b.point.first);
}
else
{
return (a.point.second < b.point.second);
}
}
bool angle_compare(POINT a, POINT b)
{
return (CCW(STD.point, a.point, b.point) > 0);
}
int main()
{
vector<POINT> pt;
int N;
scanf("%d", &N);
pt.resize(3*N);
for(int i = 0 ; i < 3*N ; i++)
{
scanf("%lld %lld", &pt[i].point.first, &pt[i].point.second);
pt[i].index = i+1;
}
while(pt.size())
{
sort(pt.begin(), pt.end(), pair_compare);
STD = pt[0];
sort(pt.begin()+1, pt.end(), angle_compare);
for(int i = 0 ; i < 3 ; i++)
{
printf("%d", pt[i].index);
if(i == 2)
{
printf("\n");
}
else
{
printf(" ");
}
}
for(int i = 0 ; i < 3 ; i++)
{
pt.erase(pt.begin());
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |