#P2087. GTY's Experimental Simulation
GTY's Experimental Simulation
GTY's Experimental Simulation
GTY summons $$n$$ people to perform experiments in a house with $$m$$ rooms. Initially, all participants are in room 1. GTY can issue two types of commands:
- Move Command: In the format "1 p r", the person with index $$p$$ is commanded to move to room $$r$$.
- Experiment Command: In the format "2 L R", experiments are conducted in every room from $$L$$ to $$R$$ (inclusive). In each room, the experiment yields points equal to the number of people in that room who have not participated in an experiment in that specific room before. Note that if a person has already participated in an experiment in that room, they will not contribute additional points even if they participate again.
After processing all commands, output the total accumulated experimental information points.
inputFormat
The first line contains three integers $$n$$, $$m$$, and $$q$$ --- the number of people, the number of rooms, and the number of commands, respectively.
The following $$q$$ lines each contain a command in one of the following formats:
1 p r
— Command person with index $$p$$ to move to room $$r$$.2 L R
— Conduct experiments in every room from $$L$$ to $$R$$ (inclusive).
outputFormat
Output a single integer representing the total accumulated experimental information points after all commands have been processed.
sample
3 3 4
2 1 1
1 1 2
2 1 2
2 2 3
4
</p>