Could anyone help me understand why I get a WA on this?


What if the given coordinates are same as the coordinate on which he starts. Then it should print YES 0 whereas you code prints NO
Second thing is, suppose starting coordinate is 0,0 and the given coordinate is 1,0 and the string is LRUD. It should give YES 1, whereas your code prints NO


Updated the condition for same destination coordinate as starting coordinate.
It gives TLE now :frowning:


UPDATE: With scanf & printf I’m still getting WA.

0 0
4 -0
0 0
-1 -1
3 3
2 2

consider these test cases your code is giving wrong output on these test cases.
i tried running your code on codechef online ide with these test cases it is also giving runtime error SIGCONT

Getting expected output. Idk what you’re trying to say! :confused:

Passing map everytime in the query was giving you TLE. I just put the whole solve function in your Query loop and got AC. Your AC Solution

1 Like

I wonder why passing a map would cause a TLE,it’s not like I am recomputing the map for every query.:confused:

You were passing the map and s by value, so both would be copied each time. Copying s Q times is obviously very expensive :slight_smile:


unfortunately i had not captured the screenshot but at that time when i tried to run your code i got the runtime error.
may be i had missed something while copying the code or something else went wrong.