#K12746. Logistic Robot Simulator
Logistic Robot Simulator
Logistic Robot Simulator
An automated delivery robot is employed by a logistics company to distribute packages along a linear series of n warehouses. The robot starts at warehouse 0 and must execute c commands. Each command instructs the robot to either move left, right, or drop off a number of packages at its current warehouse.
Commands are given in one of the following formats:
- L x: Move left by x warehouses. The robot cannot move left past index 0.
- R x: Move right by x warehouses. The robot cannot move right past index n-1.
- D x: Drop x packages at the current warehouse.
After processing all commands, output the number of packages at each warehouse in order. The movement constraints can be formally expressed as:
$$0 \leq \text{position} \leq n-1$$
inputFormat
The input is read from stdin and consists of multiple lines:
- The first line contains two integers n and c, representing the number of warehouses and the number of commands, respectively.
- The next c lines each contain a command in the format described above.
outputFormat
Output a single line to stdout containing n integers separated by spaces. The ith integer represents the number of packages delivered to warehouse with index i.
## sample5 6
R 2
D 3
L 1
D 2
R 3
D 1
0 2 3 0 1