All submissions for this problem are available.
Given a undirected graph find the number of connected components.
First line of the input is 't'- number of test case.
Followed by N, the number of vertices (Numbered 0 to N-1).
Followed by 'e' number of edges.
Followed by description of 'e' edges in the form 'a b' I.e. an edge exist between vertex a and b.
2 <= N <= 100000
0 <= e <= N/2
One line per test case, number of connected components in the graph.
Input: 2 4 2 0 1 0 2 8 0 Output: 2 8
|Time Limit:||0.117647 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions