#C7950. Circular Track Operations
Circular Track Operations
Circular Track Operations
You are given n agents positioned on a circular track with m positions numbered from 1 to m. Each agent starts at an initial position. You will then perform q operations.
Each operation is of one of the following two types:
1 x
: Move the agent numbered x one step forward. The track is circular, so if the agent is at position m, it moves to position 1.2 x
: Query the current position of agent x and output the result.
Your task is to process all the operations and output the results of the query operations in the order they appeared.
Note: The agents are numbered starting from 1.
The movement operation always applies immediately and affects subsequent queries.
inputFormat
The first line of input contains three space-separated integers: n, m, and q, where n is the number of agents, m is the number of positions on the circular track, and q is the number of operations to perform. The second line contains n space-separated integers representing the initial positions of the agents. Each of the following q lines contains an operation in the format "op x", where op is either 1 or 2. In case of op = 1, the agent x moves one step forward. For op = 2, you should output the current position of agent x.
outputFormat
For each query operation (when op = 2), output the current position of the corresponding agent on its own line.## sample
5 10 7
1 3 5 7 9
1 1
2 1
1 3
1 3
2 3
2 5
1 5
2
7
9
</p>