# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3538 | hhosu107 | Divide into triangle (kriii1_D) | C++98 | 0 ms | 1088 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>
int N;
#define T 6
int no[T];
int dot[T][2];
double angle[T][2];
void swap(int *, int *);
void swap2(double *, double *);
int main(){
int i = 0;
scanf("%d", &N);
while(N--){
do{
scanf("%d %d", &dot[i][0], &dot[i][1]);
if(dot[i][0] == 0) angle[i][1] += 0.5;
else angle[i][0] = (double)dot[i][1] / (double)dot[i][0];
if(angle[i][0] < 0.0) angle[i][1] += 1.0;
if(dot[i][1] < 0 || (dot[i][1] == 0 && dot[i][0] < 0)) angle[i][1] += 1.0;
i++;
no[i - 1] = i;
}while(i % 3);
}
int j, k;
for(j = 0; j < i - 1; j++){
for(k = j + 1; k < i; k++){
if(angle[j][1] > angle[k][1]){
swap2(&angle[j][0], &angle[k][0]);
swap2(&angle[j][1], &angle[k][1]);
swap(&dot[j][0], &dot[k][0]);
swap(&dot[j][1], &dot[k][1]);
swap(&no[j], &no[k]);
}
else if(angle[j][1] == angle[k][1]){
if(angle[j][0] > angle[k][0]){
swap2(&angle[j][0], &angle[k][0]);
swap2(&angle[j][1], &angle[k][1]);
swap(&dot[j][0], &dot[k][0]);
swap(&dot[j][1], &dot[k][1]);
swap(&no[j], &no[k]);
}
else if(angle[j][0] == angle[k][0]){
if(dot[j][0] * dot[j][0] > dot[k][0] * dot[k][0]){
swap2(&angle[j][0], &angle[k][0]);
swap2(&angle[j][1], &angle[k][1]);
swap(&dot[j][0], &dot[k][0]);
swap(&dot[j][1], &dot[k][1]);
swap(&no[j], &no[k]);
}
}
}
}
}
j = 0;
do{
printf("%d %d %d\n", no[3 * j], no[3 * j + 1], no[3 * j + 2]);
j++;
}while(j * 3 != i);
return 0;
}
void swap(int *x, int *y){
int temp;
temp = *x;
*x = *y;
*y = temp;
}
void swap2(double *x, double *y){
double temp;
temp = *x;
*x = *y;
*y = temp;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |