Find the Complement of a Graph
Given an undirected graph with
eedges, you are asked to find its complement.
The complement of a graph is a graph that has edges between all the nodes that don’t have an edge in the original one, while at the same time, not having an edge between vertices where an edge is present in the original graph.
The first line of the input contains two integers
v(1 ≤ v ≤ 500) and
e(1 ≤ e ≤ 100 000).
elines contain pairs of integers
v2(1 ≤ v1, v2 ≤ v) which means that the vertex
v1is connected to the vertex
v2and vice versa.
The program should print the adjacency list of the complement graph. Each row should start with the id of a vertex followed by a semicolon (
:) and then its connections. The connections on each row should be separated by a space. The order of both the vertices and the connections can be arbitrary.
4 4 1 2 4 2 4 1 3 4
1: 3 2: 3 3: 1 2 4:
Time limit: 1 seconds
Memory limit: 512 MB
Output limit: 1 MB