How Many Components?
You Have been Given An Undirected Graph With N vetices and you Have to handle M Queries . we Have Two Type of Queries . (1) add an edge between two vertices (2) print how many components does this graph have ? . at the begining there is no edge in the graph
InputThe first line of the standard input contains the number 1<=N<=100000, where N corresponds to the number of vertices and the Number 1<=M<=100000 where M corresponds to the number of Queries . In The Next M Lines M Queries will be Given to you . if the Query Start wiht 'A' it means you should add edge between the two vertices that will be given after 'A' in the line . if the Query Start with 'C' you should print the number of the components of the present graph .
OutputTo the standard output write T number that i-th nubmer is the Answer for the i-th Query which Start with 'C'
Input:
4 8
A 1 2
C
A 2 1
C
A 2 3
A 1 3
C
COutput:
3 3 2 2 Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.