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

Common Board

Why online judge shows comp error on C++ code?
Posted by Ivo 22 Sep 2001 14:52
See this code the judge says comp. error but
it is right!

/* @JUDGE_ID: 11754GA 5 C++ */
#include <iostream.h>
#include <MATH.h>

const max = 100;

typedef struct { float x; float y;} TPoint;

TPoint a[max];
int br=0,n;

void swap(TPoint& x,TPoint& y)
{
 TPoint z=x; x=y; y=z;
}


void QSort(int l,int r)
{
 int i=l, j=r, x=abs(a[(i+j)/2].y-a[(i+j)/2].x);
 do
 {
   while (x>abs(a[i].y-a[i].x)) i++;
   while (x<abs(a[j].y-a[j].x)) j--;
   if ( i<=j) swap(a[i++],a[j--]);
 } while (i<j);
 if (j>l) QSort(l,j);
 if (i<r) QSort(i,r);
}

void QSort2(int l,int r)
{
 int i=l, j=r, x=abs(a[(i+j)/2].x);
 do
 {
   while (x>a[i].x) i++;
   while (x<a[j].x) j--;
   if ( i<=j) swap(a[i++],a[j--]);
 } while (i<j);
 if (j>l) QSort2(l,j);
 if (i<r) QSort2(i,r);
}


void InPu()
{
 cin>>n;
 for (int i=1;i<=n; i++)
 {
  int x,y;
  cin>>x>>y;
  if (x<y){ a[++br].x=x; a[br].y=y; }
  else {a[++br].x=y; a[br].y=x; }
 }
}

void DelBad1()
{
 for (int i=1;i<=n; i++)
 {
  if (a[i].x!=1000)
   for (int j=i+1; j<=n; j++)
    if ( (a[j].x!=1000) && (a[j].x<a[i].x) && (a[j].y>a
[i].y) )
    { a[j].x=1000; a[j].y=1000; }
 }
}

void DelBad2()
{
 for (int i=1; i<=n; i++)
 {
  int loshi=0;
  if (a[i].x!=1000)
   for (int j=1; j<=n; j++)
     if ( (i!=j) && (a[j].x!=1000) )
       if ( ((a[i].x<a[j].x) && (a[i].y>a[j].x)) ||
        ((a[i].x<a[j].y) && (a[i].y>a[j].y)) )
       { loshi++; if (loshi>1) { a[i].x=1000; a[i].y=1000;
break; } }
 }
}

void DelBad3()
{
 for (int i=1; i<=n; i++)
 {
  if (a[i].x!=1000)
   for (int j=1; j<=n; j++)
     if ( (i!=j) && (a[j].x!=1000) )
       if ( ((a[i].x<a[j].x) && (a[i].y>a[j].x)) ||
        ((a[i].x<a[j].y) && (a[i].y>a[j].y)) )
       { a[j].x=1000; a[j].y=1000;}
 }

}

void main()
{
 InPu();
 QSort(1,n);

 DelBad1();
 QSort2(1,n);
 for (int i=1; i<=n; i++)
  if (a[i].x==1000) {n=i-1; break; }

 DelBad2();
 QSort2(1,n);
 for (i=1; i<=n; i++)
  if (a[i].x==1000) {n=i-1; break; }

 DelBad3();
 QSort2(1,n);
 for (i=1; i<=n; i++)
  if (a[i].x==1000) {n=i-1; break; }

 cout<<n<<endl;
 for (i=1; i<=n; i++)
  cout<<a[i].x<<" "<<a[i].y<<endl;
}
Re: Why online judge shows comp error on C++ code?
Posted by Ivo 22 Sep 2001 15:20
> See this code the judge says comp. error but
> it is right!
>
> /* @JUDGE_ID: 11754GA 5 C++ */
> #include <iostream.h>
> #include <MATH.h>
>
> . . . .
well, this is really a bad idea to post your code,
especially when the contest is not over. . .
Yeah, but if something is wrong with the judge...
Posted by Ivo 22 Sep 2001 15:36
wHY is not it working when it runs perfect on my computer...