# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3552 | pmpmp | Divide into triangle (kriii1_D) | C++98 | 0 ms | 1760 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, n1, n2, n3;
}tree;
tree h[1500], hx[1500];
//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; }
bool cmp2(tree a, tree b){ return a.n1<b.n1; }
int main ()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int a, b, c, i, j, k, s=0, t=0, aa, bb, cc;
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[j].nu<h[k].nu){ aa=h[i].nu; bb=h[j].nu; cc=h[k].nu; }
if(h[k].nu<h[j].nu && h[j].nu<h[i].nu){ aa=h[k].nu; bb=h[j].nu; cc=h[i].nu; }
if(h[j].nu<h[i].nu && h[i].nu<h[k].nu){ aa=h[j].nu; bb=h[i].nu; cc=h[k].nu; }
if(h[k].nu<h[i].nu && h[i].nu<h[j].nu){ aa=h[k].nu; bb=h[i].nu; cc=h[j].nu; }
if(h[i].nu<h[k].nu && h[k].nu<h[j].nu){ aa=h[i].nu; bb=h[k].nu; cc=h[j].nu; }
if(h[j].nu<h[k].nu && h[k].nu<h[i].nu){ aa=h[j].nu; bb=h[k].nu; cc=h[i].nu; }
//if(h[i].nu>h[j].nu){ if(){} else{} }
//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;
//hx[t][0]=aa; hx[t][1]=bb; hx[t][2]=cc; t++; h[i].n=-1; h[j].n=-1; h[k].n=-1; break;
hx[t].n1=aa; hx[t].n2=bb; hx[t].n3=cc; t++; h[i].n=-1; h[j].n=-1; h[k].n=-1; break;
} break;
}
}
sort(hx,hx+t,cmp2);
for(i=0;i<t;i++)
{
printf("%d %d %d\n", hx[i].n1, hx[i].n2, hx[i].n3);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |