【例66.1】 图论入门
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Description
Suppose an array is used to represent the adjacency matrix of a directed graph:
(1) Write a function to determine the out-degree of a vertex.
(2) Write a function to determine the in-degree of a vertex.
(3) Write a function to determine the number of edges in the graph.
Input Format
The first line: total number of nodes , specified node , nodes are numbered starting from .
The next lines: the adjacency matrix of the directed graph.
Output Format
The first line outputs three numbers: node number , the out-degree of , and the in-degree of (separated by spaces).
The second line outputs: the total number of edges in the graph.
Sample
5 3
0 4 2 2 3
2 0 1 5 10
2 0 0 4 0
0 3 7 0 7
6 2 0 0 03 2 3
15
20251129 C班作业(8)
- Status
- Done
- Problem
- 3
- Open Since
- 2025-11-29 0:00
- Deadline
- 2025-12-7 23:59
- Extension
- 24 hour(s)