# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3496 | pmpmp | Divide into triangle (kriii1_D) | C++98 | 0 ms | 1688 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 <stdio.h>
using namespace std;
typedef struct{
int x, y, n, nu;
}tree;
tree h[500];
int hx[500][3];
bool cmp(tree a, tree b){ if(a.y==b.y){ return a.x<b.x; } return a.y>b.y; }
int main ()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int a, b, c, i, j, k, s=0, t=0;
scanf("%d", &a);
for(i=1;i<=3*a;i++)
{
scanf("%d %d", &b ,&c); h[i].x=b; h[i].y=c; h[i].nu=i; //printf("%d %d %d %d\n", i, h[i].nu, h[i].x, h[i].y);
}
sort(h+1,h+1+3*a,cmp);
//for(i=1;i<=3*a;i++){printf("%d %d %d\n", h[i].x, h[i].y, h[i].nu);}
for(i=1;i<=3*a-2;i++)
{
if(h[i].n!=0){continue;}
for(j=i+1;j<=3*a-1;j++)
{
if(h[j].n!=0){continue;}
for(k=j+1;k<=3*a;k++)
{
if(h[k].n!=0){continue;}
if(h[i].x==h[j].x && h[j].x==h[k].x){continue;}
if(h[i].y==h[j].y && h[j].y==h[k].y){continue;}
//if(h[i].nu>h[j].nu>h[k].nu){ hx[t][0]=h[k].nu; hx[t][0]=h[j].nu; hx[t][0]=h[i].nu; }
//if(h[k].nu>h[j].nu>h[i].nu){ hx[t][0]=h[i].nu; hx[t][0]=h[j].nu; hx[t][0]=h[k].nu; }
//if(h[j].nu>h[i].nu>h[k].nu){ hx[t][0]=h[k].nu; hx[t][0]=h[j].nu; hx[t][0]=h[i].nu; }
hx[t][0]=h[i].nu; hx[t][1]=h[j].nu; hx[t][2]=h[k].nu; t++; h[i].n=-1; h[j].n=-1; h[k].n=-1; s=1; break;
} break;
}
}
for(i=0;i<t;i++)
{
printf("%d %d %d\n", hx[i][0], hx[i][1], hx[i][2]);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |