| 
 | 
back to boardWhat is type of the route numbers... Posted by  Sid 16 Apr 2005 22:49 I have 2 qwestions: 1)what is type of route number 2)I got Memory limit#3... but I use lists... and can't understand where I use so much memory (Perhaps the couse is recursive function but i'm not sure)   #include <iostream.h> bool bisy[1001]; short prev[1001]; short hod[1001]; short numb[1001];   struct node {     short numb;     short smej;     node* next; }; node* ar[1001]; void rec(short rr,short step) {     node* g;     g=ar[rr];
      while (g!=NULL)     {         if (hod[g->smej]==-1 ||hod[g->smej]<step && !bisy[g->numb])     {         hod[g->smej]=step;         numb[g->smej]=g->numb;         prev[g->smej]=rr;         bisy[g->numb]=true;         rec(g->smej,step+1);         bisy[g->numb]=false;     }     g=g->next;     }
  } void print(int x) {     if (hod[x]>0)     {         print(prev[x]);         cout<<numb[x]<<"\n";     } } int main() {
      int j,k,n,v1,v2,r;     for (j=0;j<1001;j++)     {         ar[j]=NULL;         bisy[j]=false;         prev[j]=-1;         numb[j]=-1;         hod[j]=-1;     }     cin>>n;     node* d;     for(k=0;k<n;k++)     {         cin>>v1>>v2;         d=new node;         d->numb=k+1;         d->smej=v2;         d->next=ar[v1];         ar[v1]=d;     }     cin>>r>>v1>>v2;     hod[v1]=0;     hod[v2]=0;     rec(v1,1);     rec(v2,1);     if (hod[r]==-1)     {         cout<<"IMPOSSIBLE\n";         return 0;     }     cout<<hod[r]<<"\n";
      print(r);     return 0; }    |  
  | 
|