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 1096. Get the Right Route Plate!

My program got Wrong answer .Help me please!
Posted by crazy 22 Apr 2002 11:20

I use BFS in the program
#include<iostream.h>
long x[2000],y[2000];
int queue[2000];
int parent[2000];
int path[2000];
int in[2000];
void main()
{

 int n;
 int i,j,tot,current,step;
 int temp;
 long need;
 cin>>n;
 for(i=1;i<=n;i++){
   in[i]=0;
   cin>>x[i]>>y[i];
 }
 cin>>need>>x[0]>>y[0];

 queue[0]=0;
 current=0;
 tot=1;
 while(current<tot){
     if(x[queue[current]]==need||y[queue[current]]==need) break;
     for(i=1;i<=n;i++){
         if(!in[i]){
             if((x[i]==x[queue[current]])||(x[i]==y[queue
[current]])||(y[i]==x[queue[current]])||(y[i]==y[queue[current]])){
               queue[tot]=i;
               parent[i]=queue[current];
               in[i]=1;
               tot++;
             }
         }
     }
     current++;
 }

 if(x[queue[current]]==need||y[queue[current]]==need){
     step=0;
     temp=queue[current];
     while(1){
      if(temp==0) break;
      step++;
      path[step]=temp;
      temp=parent[temp];
     }
     cout<<step<<endl;
     for(j=step;j>=1;j--){
      cout<<path[j]<<endl;
     }
 }else{
  cout<<"IMPOSSIBLE"<<endl;
 }
}
Re: My program got Wrong answer .Help me please!
Posted by crazy 23 Apr 2002 15:30

when i change

if((x[i]==x[queue[current]])||(x[i]==y[queue[current]])
  ||(y[i]==x[queue[current]])||(y[i]==y[queue[current]]))
{}

into

if((x[i]==x[queue[current]])||(x[i]==y[queue[current]])
{}

i get ac.
i did not read the problem carefully
Anyone who got wrong answer should pay attention to it
Re: My program got Wrong answer .Help me please!
Posted by elmariachi1414 (TNU) 14 Jan 2008 19:07
Thanks! But where it is mentioned in the problem statement???
Re: My program got Wrong answer .Help me please!
Posted by PersonalJesus 10 Apr 2008 18:38
Another THANKS from me, but really where is that mentioned in the problem's statement ?
Re: My program got Wrong answer .Help me please!
Posted by Nikola Milosavljevic 17 Apr 2008 21:08
THANKS, man!

Well, there is a sentence in text:

"The next K lines contain the number of the route of the corresponding bus and the number on the other side of its plate."

But it is not explicitly said that first number in line is route number and that second number is from the other side of plate...

Anyway, the point is that you can change your plate with driver i (which has plate x[i],y[i]) iff one of the numbers on your plate is x[i] (not x[i] OR y[i]).