OlveraeUNSW
Back to problems
COMP2521

24T2 Q11 — Day trip

Road network with two N×N adjacency matrices: standard roads then highways. In one day you may take either one standard edge, or a path of one or two consecutive highway edges. stdin: N START, the standard matrix, then the highway matrix. Print, ascending and space-separated, every vertex (≠ START) reachable from START within one day.


Single-file C (gcc -O0 -Wall). Self-contained reframing of the exam's ADT-completion question. From COMP2521 24T2 Sample.

Samples

stdin
4 0
0 1 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 1 0
0 0 0 0
0 0 0 1
0 0 0 0
expected
1 2 3
c-gcc
14