#C. 图的遍历

    Type: Default 1000ms 256MiB

图的遍历

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.

说明

   写出图的深度优先搜索(DFS)算法和广度优先搜索(BFS)算法(dfsbfs)

输入格式

   第一行为图的结点数n,下面的n行为每个结点的名字,第n+2行为边的数目e,以下e行为有边的结点对。(1<=n<=100

输出格式

  两行,第一行为深度优先搜索后的序列,第二行为广度优先搜索后的序列。

样例

4
a
b
c
d
2
1 2
3 4
abcd
abcd

数据结构—树、图(初步)

Not Claimed
Status
Done
Problem
6
Open Since
2025-3-15 0:00
Deadline
2025-3-23 23:59
Extension
24 hour(s)