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 does this program gets COMPILATION ERROR?!?!?! :(
Posted by ijk 20 Apr 2002 12:46
#include<iostream.h>

#define BUSES 100
#define STOPS 100
#define FRIENDS 100

short N, M, K;
short stops[BUSES][STOPS+1];
short buses[STOPS][BUSES+1];
int   **a;
int   money[FRIENDS];
short init[FRIENDS];
short month[FRIENDS];
short InTurn;
long mins[100];


void visit(short st, int steps)
{
short s, b, bus, stop;
    for (b=1; b<=buses[st][0]; b++)
    {
        bus = buses[st][b];
        for (s=1; s<=stops[bus][0]; s++)
            if (stops[bus][s]==st) break;
        for (s++; s<=stops[bus][0]; s++)
        {
            stop = stops[bus][s];
            if (steps < a[InTurn][stop])
            {
                a[InTurn][stop] = steps;
                visit(stop, steps+4);
            }
        }
    }
}

void main()
{
short s, ss, i, j, k, l;
    cin>>N>>M;
    for (i=0; i<M; i++) stops[i][0]=0;
    for (j=0; j<N; j++) buses[j][0]=0;
    for (i=0; i<M; i++)
    {
        cin>>k;
        for (j=0; j<k; j++)
        {
            cin>>l;
            --l;
            stops[i][++stops[i][0]]=l;
            buses[l][++buses[l][0]]=i;
        }
    }
    cin>>K;
    for (i=0; i<K; i++)
    {
        cin>>money[i]>>init[i]>>month[i];
        --init[i];
    }
    a = new int*[N];
    for (s=0; s<N; s++)
        a[s] = new int[N];
    for (s=0; s<N; s++)
    {
            for (ss=0; ss<N; ss++)
                a[s][ss] = 32767;
            a[s][s]=0;
        InTurn = s;
        visit(s,4);
    }
    for (j=0; j<N; j++)
    {
        mins[j]=-1;
        for (i=0; i<K; i++)
        {
            if (a[init[i]][j]==32767 ||
                 a[init[i]][j]>money[i])
                 goto process_next;
        }
        mins[j]++;
        for (i=0; i<K; i++)
        mins[j]+=(a[init[i]][j]*(1-month[i]));
        process_next:
    }
    for (s=0; s<N; s++)
        delete[] a[s];
    delete[] a;
    for (i=0; i<N; i++)
        if (mins[i]<0) mins[i]=2147483646;
short pos = 0;
    for (i=1; i<N; i++)
        if (mins[i]<mins[pos]) pos = i;
    if (mins[pos]==2147483646)
        cout<<0;
    else
    {
        cout<<(pos+1)<<" ";
        cout<<mins[pos]<<endl;
    }
}