ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1028. Stars

WHY WA???What's wrong with my code?
Posted by michel mizrahi 10 Apr 2005 03:41
I don't understand Why I get WA in test #9. I have test it with some random tests and it works fine
here is my code:

#include <stdio.h>
int x[15003],y[15003];

swap(i,p){
    int tmp=x[i];
    x[i]=x[p];
    x[p]=tmp;
    tmp=y[i];
    y[i]=y[p];
    y[p]=tmp;
}

quick_s(int l, int h){
    int p;
    if(h>l){
        p=partition(l,h);
        quick_s(l,p-1);
        quick_s(p+1,h);
    }
}

partition(int l, int h){
     int p=l,i,j;
     for(i=l;i<h;i++){
         if(x[i]<x[h]){
                swap(i,p);
                p++;
         }
     }
     swap(i,p);
     return p;
}


int main(){
    int n,i,s[15003],j,k;
  scanf("%d",&n);
  for(i=0;i<n;i++)
        scanf("%d %d",&x[i],&y[i]);
    quick_s(0,n-1);
  for(j=n-1;j>-1;j--){
      k=0;
    for(i=j-1;i>-1;i--)
        if(y[j]>=y[i]) k++;
      for(i=j+1;i<n;i++){
           if(x[i]!=x[j]) break;
          if(y[j]>=y[i]) k++;
    }
    s[k]++;
}
    for(i=0;i<n;i++)
     printf("%d\n",s[i]);
   return 0;
}

If someone can help me I would appreciate very much!
thanks