#C10758. Robot Position Manager
Robot Position Manager
Robot Position Manager
You are given n robots labeled from 1 to n and a sequence of m commands. Each command is either a command to set a robot's position or a query to retrieve its current position. Initially, no robot has an assigned position.
The commands are of two types:
- Type 1 (Update Command): In the format
1 i p
which assigns the position p to the robot with identifier i. - Type 2 (Query Command): In the format
2 i
which requires you to output the current position of the robot with identifier i. If no position has yet been assigned, outputNone
.
</p>
Input/Output via standard input and output.
Note: All the numerical positions are integers. In the output, each query result should be printed on a separate line.
inputFormat
The first line of input contains two integers n and m separated by a space, where n is the number of robots and m is the number of commands.
The following m lines each contain a command. A command is either in the format 1 i p
for updating the position of robot i to position p, or 2 i
for querying the current position of robot i.
outputFormat
For each query command (type 2), output the current position of the respective robot on a separate line. If a robot has not been assigned any position, output None
.
3 5
1 1 5
1 2 7
2 1
1 1 2
2 1
5
2
</p>