| 
 | 
back to board[WA #2] why my code got WA #2 This is my code. I don't know why got the WA #2. But When I use the sample in the forum, I got the same answer as result in the forum.   Could someone tell my which place take wrong? I really appreciate you.     #include<stdio.h> #include<stdlib.h> #include<string.h>   typedef struct{     int right;     int left;     int index;     int win;     int lose; }segment;     int contain(segment a,segment b){     if (a.left > b.left  &&  a.right < b.right ) return 1;     else return 0; }
    int main(){       int i,j,m,num;     segment point[500],tmp;     memset(point , '\0' , sizeof(point) );       scanf("%d",&num);     if(num < 0 || num > 500) exit(0);       for(i = 0 ; i <  num ; i++){         scanf("%d %d",&point[i].left , &point[i].right );         if(point[i].left > 10000 || point[i].left < -10000) exit(0);         else if(point[i].right > 10000 || point[i].right < -10000) exit(0);         point[i].index = i;     }       for(i = 0 ; i < num ; i++){         if(point[i].left > point[i].right){                            m = point[i].left;                point[i].left = point[i].right;               point[i].right =  m ;         }     } /*    for(i = 0 ; i < num ; i ++){        printf("%2d %2d\n",point[i].left , point[i].right);    } */    for (i = 0 ; i <  num ; i++){         for(j = 0; j < num; j++){                if( ( i != j )   &&   (  contain( point[i] , point[j] )  )   ){   /*                  printf("i = %d j = %d \n" , i, j);      */                       point[i].lose ++;                       point[j].win ++;                }         }    } /*    for(i = 0 ; i < num ; i ++){        printf("%2d %2d\n",point[i].win , point[i].lose);    } */    for(i = 0 ; i < num ; i ++){          for(j = i ; j < num ; j++ ){                  if ( point[i].lose  <  point[j].lose ){
                           tmp = point[i];                     point[i] = point[j];                     point[j] = tmp ;                  }          }    }      for(i = point[0].lose  ; i < num ; i ++){          for(j = i ; j < num ; j++ ){                  if ( point[i].win  <  point[j].win ){                          tmp = point[i];                     point[i] = point[j];                     point[j] = tmp ;                  }          }    }
     printf("%d\n",point[0].lose + 1);
     for(i = 0 ; i <= point[0].lose  ; i ++){        printf("%d ",point[i].index+1);    }   return 0; }  |  
  | 
|