#E. 图的宽度优先遍历

    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.

题目描述

读入一个用邻接矩阵存储的无向图,输出它的宽度优先遍历序列。

输入

第1行1个正整数n,表示图中顶点数,2≤n≤100;

接下来的n行是一个n*n的邻接矩阵,a[i][j]=1表示顶点i和顶点j之间有直接边相连,a[i][j]=0表示没有直接边相连。保证i=j时,a[i][j]=0,并且a[i][j]=a[j][i]。

输出

输出1~n的某一种排列,表示从顶点1开始,对该图进行宽度优先遍历得到的顶点序列,每两个数之间用一个“-”分隔。

8
0 1 1 0 0 0 0 0
1 0 0 1 1 0 0 0
1 0 0 0 0 0 1 1
0 1 0 0 0 1 0 0
0 1 0 0 0 1 0 0
0 0 0 1 1 0 0 0
0 0 1 0 0 0 0 1
0 0 1 0 0 0 1 0
1-2-3-4-5-7-8-6

骁骁训练计划-队列

Not Claimed
Status
Done
Problem
9
Open Since
2025-1-9 0:00
Deadline
2025-1-25 23:59
Extension
24 hour(s)