# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
3833 | hyeonjae0310 | Divide into triangle (kriii1_D) | C++98 | 0 ms | 1240 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef struct POINT
{
pair<int, int> point;
int index;
}POINT;
POINT STD;
int CCW(pair<int, int> a, pair<int, int> b, pair<int, int> 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("%d %d", &pt[i].point.first, &pt[i].point.second);
pt[i].index = i+1;
}
while(!pt.empty())
{
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.front().index);
pt.erase(pt.begin());
}
printf("\n");
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |