CENS2020 Help Martha showing WA

The CENS2020 2nd question (Help Martha)

Jonas asked Martha to stand at point (x1,y1)(x1,y1) on an infinite cartesian plane. He gave her a string SS which consists of operations in the form of characters ‘R’ , ‘L’ , ‘U’ , and ‘D’ .

Each character of the string corresponds to the following movements:

  • ’R’ means moving right by 11 unit i.e, (x,y)(x,y) to (x+1,y)(x+1,y).
  • ’L’ means moving left by 11 unit i.e, (x,y)(x,y) to (x−1,y)(x−1,y).
  • ’U’ means moving up by 11 unit i.e, (x,y)(x,y) to (x,y+1)(x,y+1).
  • ’D’ means moving down by 11 unit i.e, (x,y)(x,y) to (x,y−1)(x,y−1).

Now, Jonas asks Martha QQ queries. In each query, coordinates are given of form (x2,y2)(x2,y2). Martha needs to tell if it is possible to move from (x1,y1)(x1,y1) to (x2,y2)(x2,y2) by choosing a subsequence of given string SS and performing the operations in sequential order.Starting point (x1,y1)(x1,y1) remains same for all queries.

If it is possible, print “YES” and the length of the smallest possible subsequence of string, else print “NO” .

for this i submitted this solution https://www.codechef.com/viewsolution/37001044.It is showing WA can anyone suggest where did i go wrong?
thanks in advance :slight_smile: