From adjacency matrix to adjacency list#3981

From adjacency matrix to adjacency list

1 sekunda
128 megabajtów
Bardzo łatwe

A simple directed graph is given by its adjacency matrix. Print its representation as adjacency list.

Dane wejściowe

The first line contains the number n~(1 \le n \le 100) of vertices in the graph. Each of the following lines contains integers — the adjacency matrix. It is guaranteed that the graph has no self-loops.

Dane wyjściowe

Print lines — the adjacency list of the graph. In the -th line, first print the number of edges going out from vertex , followed by the numbers of the vertices they point to, in ascending order.

Przykłady

Przykład 1

Loading
Loading