Submission #3496

# Submission time Handle Problem Language Result Execution time Memory
3496 2013-08-31T06:11:30 Z pmpmp Divide into triangle (kriii1_D) C++
0 / 1
0 ms 1688 KB







#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
1 Correct 0 ms 1688 KB Output is correct
2 Correct 0 ms 1688 KB Output is correct
3 Correct 0 ms 1688 KB Output is correct
4 Correct 0 ms 1688 KB Output is correct
5 Correct 0 ms 1688 KB Output is correct
6 OK 0 ms 1688 KB
7 Halted 0 ms 0 KB -