-->
当前位置:首页 > 题库

PROGRAMMING:Generating inverse adjacency table from adjacency table

Luz5年前 (2021-05-10)题库388
Given a digraph, a total of N nodes (n < = 1000), e edges, each node is the number of int type, establish the adjacency table, according to the
Adjacency table generates inverse adjacency table. The graph structure stored in adjacency table and inverse adjacency table is output in descending order, separated by empty rows
If the edge list of vertex attachment is empty, '0' is used【 Test case: IOT engineering level 16 [Lai Meiling]
###Input format:
First, input the number of vertices N and the number of edges m, input each vertex according to the number increasing order, and then input the relationship of edges in turn, that is, all edges
Arc tail and arc head, separated by a space in the middle, and finally no space. The title ensures that all arc heads and arc tails are entered in ascending order.
###Output format:
V0: P1, P2... / / adjacency table
v1:p1 p2...
.
.
.
vn p1 p2...
V0: P1, P2... / / inverse adjacency table
.
.
.
vn:p1 p2...
Among them, V0 VN and P1 P2... Are in ascending order
###Input example:
Here is a set of inputs. For example:
```in
5 7
0 1 2 3 4
0 1
1 0
1 4
2 1
2 3
3 0
4 3
```
###Output example:
The corresponding output is given here. For example:
```out
0:1
1:4 0
2:3 1
3:0
4:3
0:3 1
1:2 0
2:0
3:4 2
4:1
```







answer:If there is no answer, please comment