WA in Rescue Balin

I dont understand why this code is giving WA for

ques: http://ww2.codechef.com/problems/BYTESD

code: http://ideone.com/vEiSdF

can ne1 pls point out the error…or find a case where the code may be failing…!!!

1 Like

Final Answer:
This problem, test cases need to be verified there are multiple paths possible for some test cases and they need to be removed. i can prove that based on my submissions. If i change the ordering of DFS it gets accepted.
correct submission:2077628
wrong submission: 2077578
Please have a look whoever can :slight_smile: because i can not…

but one of the mistake is

        for(int i=0;i<m;cout<<endl,i++)
            for(int j=0;j<n;vis[i][j]=0,j++)
        cout<<"The path doesn't exist."<<endl;

here vis[i][j] = 0 will not execute if there is no path
in which case vis[i1][j1] = 1 in the subsequent test cases


@kunal361 : If some bug still remains , give link to your latest code .

1 Like

@kunal361: answer updated above…

somebody check the test cases

Just guess the difference between these two codes :



your corrected code…the mistake was that dir was global…!!!

1 Like

nope…that is not the case!!!
cause if no path is found…as the fxn returns it will make vis[i][j]=0.

still i tried re-initializing the array to 0…but WA!!

yup it makes vis[i][j]=0;
but not vis[i1][j1] =0 which you are doing in your main so its the position s which will not be reset
i agree it still gives WA … but for the other one you can test yourself once you get “no path” as answer look at ur vis array

1 Like

ya…saw that now that vis[i1][j1] remains 1…thanks for that…:slight_smile:

now m trying to find some other small bug like this 1…!!!

thanks again…:slight_smile:

the above given link is the latest as im editing on that link only…:slight_smile:

thanks a lot…changed the dfs ordering…and voila!!!

srsly some1 needs to check the ips…!!!

@bit_cracker007…1 reason is that the ip cases are not upto the mark!!!

check if ur dfs is following this order…http://www.codechef.com/viewsolution/2077664

as far as i understand…it is following the same order!!!

also check the punctuation of the path doesn’t exist as the >>’<< symbol was ambiguous during the contest!!!

@kunal361 : Yes, it is following the same order. There’s a bug I think.
@aashish_iitm : Can you figure out what’s wrong in my code ? :slight_smile:

see input #2 #7 #8 in this ideone link…http://ideone.com/jIeDBy

@bit_cracker007 i think i should close the ques cause is see that u have been AC…:slight_smile:

took us quite a while to get that small bug though…:smiley:

Thanks for your patience :slight_smile: