5350: CF EDU - DSU - Step 1 - C. Experience
[Creator : ]
Description
In a novel online game, the players fight the monsters and get the experience, as usual. To fight monsters players join together in raid teams. After the destruction of the monster, all the players of the team get the same amount of experience points. The special feature of the game is that a team cannot be split up and no one can leave a team. The only supported operation is to join two teams together.
Since there are already a lot of people playing the game, you are asked to maintain the experience points of the players.
Since there are already a lot of people playing the game, you are asked to maintain the experience points of the pla
Input
The first line of the input contains two integers $n,\ m\ (1 ≤ n, m ≤ 2·10^5)$ — the number of players and the number of queries.
Next $m$ lines contain the description of queries, one per line. A query can be of three types:
yer has $0$ experience points and each of the player is in its own team of size one.
Next $m$ lines contain the desc
-
join X Y — join two teams to which pla
yers $X$ and $Y$ belong to (if they are already in the same team, nothing changes). -
add X V — add $V\ (1 ≤ V ≤ 100)$ experience points to each pla
yer in a team to which pla yer $X$ belongs to. -
get X — output the current number of experience points of pla
yer $X$.
Output
For each query get X output the current number of experience points of player $X$ on a separate line.
Sample 1 Input
3 6
add 1 100
join 1 3
add 1 50
get 1
get 2
get 3
Sample 1 Output
150
0
50