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…!!!
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…!!!
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 because i can not…
but one of the mistake is
if(rec(i1,j1))
for(int i=0;i<m;cout<<endl,i++)
for(int j=0;j<n;vis[i][j]=0,j++)
if(vis[i][j])
cout<<c[i][j];
else
cout<<'-';
else
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
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
ya…saw that now that vis[i1][j1] remains 1…thanks for that…
now m trying to find some other small bug like this 1…!!!
thanks again…
the above given link is the latest as im editing on that link only…
thanks a lot…changed the dfs ordering…and voila!!!
thanks…
srsly some1 needs to check the ips…!!!
Just guess the difference between these two codes :
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 ?
took us quite a while to get that small bug though…
Thanks for your patience