답안 #3552

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3552 2013-08-31T06:33:12 Z pmpmp Divide into triangle (kriii1_D) C++
1 / 1
0 ms 1760 KB
#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);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1760 KB Output is correct
2 Correct 0 ms 1760 KB Output is correct
3 Correct 0 ms 1760 KB Output is correct
4 Correct 0 ms 1760 KB Output is correct
5 Correct 0 ms 1760 KB Output is correct
6 Correct 0 ms 1760 KB Output is correct
7 Correct 0 ms 1760 KB Output is correct
8 Correct 0 ms 1760 KB Output is correct
9 Correct 0 ms 1760 KB Output is correct
10 Correct 0 ms 1760 KB Output is correct
11 Correct 0 ms 1760 KB Output is correct
12 Correct 0 ms 1760 KB Output is correct
13 Correct 0 ms 1760 KB Output is correct
14 Correct 0 ms 1760 KB Output is correct
15 Correct 0 ms 1760 KB Output is correct
16 Correct 0 ms 1760 KB Output is correct
17 Correct 0 ms 1760 KB Output is correct
18 Correct 0 ms 1760 KB Output is correct
19 Correct 0 ms 1760 KB Output is correct
20 Correct 0 ms 1760 KB Output is correct