Submission #3541

# Submission time Handle Problem Language Result Execution time Memory
3541 2013-08-31T06:28:35 Z pmpmp Divide into triangle (kriii1_D) C++
0 / 1
0 ms 1704 KB
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

typedef struct{
    int x, y, n, nu, n1, n2, n3;
}tree;
tree h[500], hx[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; }
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
1 Correct 0 ms 1704 KB Output is correct
2 Correct 0 ms 1704 KB Output is correct
3 Correct 0 ms 1704 KB Output is correct
4 Correct 0 ms 1704 KB Output is correct
5 Correct 0 ms 1704 KB Output is correct
6 OK 0 ms 1704 KB
7 Halted 0 ms 0 KB -