I have a doubt regarding this question. It was mentioned that we can choose any non prohibited cell as the starting point. To reach C any of the U,D,L,R should be non prohibited. So, if I just start from any non prohibited cell that lies either U,or D,or L, or R of ‘C’ and then just take it to C using single instruction, why am I getting WA? Pardon me if I understood the question wronmg.
@karanaggarwal I started from the Capital and went to each and every city and then reversed the string and replaced L with R, U with D and vice-versa. For all my custom test cases the code worked fine. But still its not getting accepted (WA). If you could help me figure my mistake out, I would be grateful. Below is the link to my code.
Thanks
Small question - does anybody know how to find exact probability of random string of length L being a solution to some particular input file?
Like I showed in CF comment, it has at least 15% chance to fail in this problem.
Random note regarding bounds on total sum of path lengths - in order to have cell with distance 300 from capital, you need to have a cell with distance <=1, a cell with distance <=2, a cell with distance <=3 and so on - all of them will be on the path from our “bad cell” to the capital. With this observation you can safely decrease bound to something like 53k.
BTW, just curious - what’s the input file on which this algo produces longest possible string, and what’s the length of that string? 
The Qs is still accepting solutions which are randomly generated.
We had discovered it during the testing, we tried some test cases which can break some of the randomized solution. It was really hard to generate test cases for it. I would be interested if someone has a good test case to break such solutions.
What was that :3 :3 :3
“That guy would have never guessed this thing .”
That guy is one of the top competitors worldwide, so I’m pretty sure he would have.
I <3 Tanya Romanova 
This isn’t I_love_Tanya_Romanova’s solution, this is solution of Tanya Romanova ( romanova | CodeChef User Profile for Tanya Romanova | CodeChef )
Exactly lebron | CodeChef User Profile for Bohdan | CodeChef
And this is his solution : CodeChef: Practical coding for everyone
A case like this would not have allowed this: 
20 20
C…
.
…
.
…
.
…
.
…
.
…
.
…
.
…
.
…
*********.
…
..........
to enforce boundary restriction u can make the case for 1919 and then put '’ along the boundaries to get a 20*20.
I know he isn’t I_love_Tanya_Romanova, I meant to say that, I love this(not orig) Tanya Romanova 
Who told that ?
Non-determinism is something which can never be beaten-
LOL That is awesome! _/_
damn… i tried 2 different values in srand and both got WA, but srand(0) gets accepted
Would love to hear the reasoning behind this!
@xellos0 A random output is giving AC to this solution, so is there a guarantee that everyone who solved it did it correct? Maybe they also got their luck, right? What kind of problem is it?
My randomized solution with checker passes in same time as during a contest, so I’m not sure if tests are actually updated somehow.
Can you share O(N) code? If you mean area of input as N, still it sounds interesting, as you claim that you can build a good string which has size O(N).