返回题目列表
COMP2521
21T3 Q7 — 有向图是否二叉树
stdin:N,随后 N×N 有向图邻接矩阵(1 表示 i→j 边)。当且仅当它是二叉树时打印 true:恰一个根(入度 0),其余顶点入度均为 1,所有顶点出度 ≤ 2,且根可达所有顶点;否则 false。
Single-file C (gcc -O0 -Wall). Self-contained reframing of the exam's ADT-completion question. From COMP2521 21T3 Sample.
样例
stdin
5 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
期望输出
true
c-gcc
14