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
UPDATE: With scanf & printf I’m still getting WA.
2 RRRR 0 0 2 4 -0 0 0 LLLLUUUUUURRRRRRDDRR -1 -1 2 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
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
I wonder why passing a map would cause a TLE,it’s not like I am recomputing the map for every query.
You were passing the
s by value, so both would be copied each time. Copying
s Q times is obviously very expensive
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.