#K69547. Robot Return to Origin

    ID: 33110 Type: Default 1000ms 256MiB

Robot Return to Origin

Robot Return to Origin

You are given a string representing a sequence of moves performed by a robot. The moves are represented by the characters U (up), D (down), L (left), and R (right). The robot begins at the origin point \((0,0)\) on a 2D plane.

For each move, the robot moves one unit in the corresponding direction:

  • Up: \(y = y + 1\)
  • Down: \(y = y - 1\)
  • Left: \(x = x - 1\)
  • Right: \(x = x + 1\)

Your task is to determine whether the robot returns to the origin after executing the entire sequence of moves. Output true if it returns to the origin, and false otherwise.

inputFormat

A single line string containing only the characters 'U', 'D', 'L', and 'R' representing the moves of the robot.

outputFormat

Print a single line: 'true' if the robot returns to the origin (0,0), otherwise 'false'.## sample

UD
true