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 this code got CE? I can compile it by GCC.
Posted by Savior 8 Jun 2004 11:37
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

const double EPS=1e-8;
const int MAXN=100;
const int MAXM=100;

struct Tnode {
  int x,y;
  double r,c;
};

int n,m;
int s;
double v;
vector<Tnode> c;
double a[MAXN];
int ind[MAXN][2];

inline bool cmp(Tnode p1,Tnode p2)
{
  return(p1.x==p2.x)?(p1.y<p2.y):(p1.x<p2.x);
}

void read()
{
  int i,x,y;
  Tnode tmp;

  scanf("%d%d%d%lf",&n,&m,&s,&v);
  s--;
  c.clear();
  for(i=0;i<m;i++) {
    scanf("%d%d",&x,&y);
    x--,y--;
    tmp.x=x,tmp.y=y;
    scanf("%lf%lf",&tmp.r,&tmp.c);
    c.push_back(tmp);
    tmp.x=y,tmp.y=x;
    scanf("%lf%lf",&tmp.r,&tmp.c);
    c.push_back(tmp);
  }
  sort(c.begin(),c.end(),cmp);

  memset(ind,255,sizeof(ind));
  ind[c[0].x][0]=0;
  for(i=1;i<c.size();i++) {
    if(c[i].x!=c[i-1].x) {
      ind[c[i-1].x][1]=i-1;
      ind[c[i].x][0]=i;
    }
  }
  i=c.size()-1;
  ind[c[i].x][1]=i;
}

bool solve()
{
  int i,j;
  bool done;
  double u;

  for(i=0;i<n;i++) a[i]=-1.;
  a[s]=v;

  do {
    done=1;
    for(i=0;i<n;i++) if(a[i]>EPS) {
      if(ind[i][0]<0) continue;
      for(j=ind[i][0];j<=ind[i][1];j++) if(a[i]>c[j].c+EPS) {
    u=(a[i]-c[j].c)*c[j].r;
    if(a[c[j].y]<-EPS) {
      a[c[j].y]=u;
      done=0;
    }
    else {
      if(u>a[c[j].y]+EPS) return 1;
    }
      }
    }
  } while(!done);
  return 0;
}

int main()
{
  read();
  if(solve()) printf("YES\n"); else printf("NO\n");
  return 0;
}
There is no CE. Try to submit one more time.
Posted by Problemset Maintainer 8 Jun 2004 14:49