Submit | All submissions | Best solutions | Back to list |
EICONP3 - Connected Components 3 |
Given an undirected graph with n vertices and m edges. Vertices are numbered from 0 to n-1. Write a program to calculate the number of vertices and edges of each component.
Input
The first line contains the number of vertices n (1 ≤ n ≤ 105), the number of edges m (1 ≤ m ≤ 2x105).
Each of the next m lines contains 2 integers u, v representing an edge between u and v (0 ≤ u,v ≤ n).
Output
For each component, print out the smallest vertices, the number of vertices and edges in the component.
Sample
Input |
Output |
3 1 1 2
|
0 1 0 1 2 1 |
Added by: | Ha Minh Ngoc |
Date: | 2022-12-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |