A. 【例66.1】 图论入门

    Type: Default 1000ms 64MiB

【例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 n×nn \times n array aa 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 nn, specified node mm, nodes are numbered starting from 11.
The next nn lines: the adjacency matrix of the directed graph.
1n,m,a[i][j]10001\leq n, m, a[i][j]\leq 1000

Output Format

The first line outputs three numbers: node number mm, the out-degree of mm, and the in-degree of mm (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 0
3 2 3
15

20251129 C班作业(8)

Not Claimed
Status
Done
Problem
3
Open Since
2025-11-29 0:00
Deadline
2025-12-7 23:59
Extension
24 hour(s)