Make the Graph Complete
Given an undirected graph with
eedges, you are asked to find all the edges that need to be added to the graph to make it complete.
The first line of the input contains two integers
v(1 ≤ v ≤ 500) and
e(1 ≤ e ≤ ).
elines contain pairs of integers
v2(1 ≤ v1, v2 ≤ v) representing an edge between
The program should print all the edges that need to be added to the graph in lexicographical order (from the smallest vertex id to the largest). All the edges need to be printed on separate lines, while the vertices should be separated by a space.
4 3 1 2 2 3 3 1
1 4 2 4 3 4
- Vertex 4 was not initially connected to any of the vertices in the graph. So, we should connect it to all the other vertices.
Time limit: 1 seconds
Memory limit: 512 MB
Output limit: 1 MB