#include <stdio.h>
#include <string.h>
#define SIZE 50
void bfs(int matrix[][SIZE], int nodes, int start) {
int queue[nodes],
i, j,
visited[nodes],
first = 0,
last = 0,
curr;
queue[ first ] = start;
memset(visited
, 0, sizeof(visited
));
visited[ start ] = 1;
while(first <= last) {
curr = queue[first];
for(j = 1; j <= nodes; ++j)
if(0 == visited[j] && 1 == matrix[curr][ j ]) {
last = last + 1;
queue[ last ] = j;
visited[ j ] = 1;
}
first++;
}
for(i
= 0 ; i
< nodes
; ++i
) printf("%d ", queue
[i
]); }
void display(int mat[][SIZE], int nodes) {
for(int i = 1; i <= nodes; ++i) {
for(int j = 1; j <= nodes; ++j) {
}
}
}
int main(int argc, char const *argv[])
{
int matrix[SIZE][SIZE],
nodes, edges, s, i, j;
scanf("%d %d", &nodes
, &edges
);
while(edges--) {
matrix[i][j] = 1;
}
display(matrix, nodes);
bfs(matrix, nodes, 4);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2RlZmluZSBTSVpFIDUwCgoKdm9pZCBiZnMoaW50IG1hdHJpeFtdW1NJWkVdLCBpbnQgbm9kZXMsIGludCBzdGFydCkgewoKICAgICBpbnQgcXVldWVbbm9kZXNdLCAKICAgICAgICAgaSwgaiwKICAgICAgICAgdmlzaXRlZFtub2Rlc10sIAogICAgICAgICBmaXJzdCA9IDAsIAogICAgICAgICBsYXN0ID0gMCwgCiAgICAgICAgIGN1cnI7CiAgICAgCiAgICAgcXVldWVbIGZpcnN0IF0gPSBzdGFydDsKCiAgICAgbWVtc2V0KHZpc2l0ZWQsIDAsIHNpemVvZih2aXNpdGVkKSk7CgogICAgIHZpc2l0ZWRbIHN0YXJ0IF0gPSAxOyAgICAgCgogICAgIHdoaWxlKGZpcnN0IDw9IGxhc3QpIHsKCiAgICAgICAgICAgY3VyciA9IHF1ZXVlW2ZpcnN0XTsKCiAgICAgICAgICAgZm9yKGogPSAxOyBqIDw9IG5vZGVzOyArK2opIAoKICAgICAgICAgICAgICAgICAgIGlmKDAgPT0gdmlzaXRlZFtqXSAmJiAxID09IG1hdHJpeFtjdXJyXVsgaiBdKSB7CiAgICAgCiAgICAgICAgICAgICAgICAgICAJICBsYXN0ID0gbGFzdCArIDE7CgogICAgICAgICAgICAgICAgICAgCSAgcXVldWVbIGxhc3QgXSA9IGo7CgogICAgICAgICAgICAgICAgICAgCSAgdmlzaXRlZFsgaiBdID0gMTsgICAgCiAgICAgICAgICAgICAgICAgICB9ICAgICAgICAgICAKCiAgICAgICAgICAgZmlyc3QrKzsKICAgICB9ICAgICAgCgogICAgIGZvcihpID0gMCA7IGkgPCBub2RlczsgKytpKSBwcmludGYoIiVkICIsIHF1ZXVlW2ldKTsKfQoKdm9pZCBkaXNwbGF5KGludCBtYXRbXVtTSVpFXSwgaW50IG5vZGVzKSB7CgogICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gbm9kZXM7ICsraSkgewoKICAgICAJZm9yKGludCBqID0gMTsgaiA8PSBub2RlczsgKytqKSB7CgogICAgIAkJcHJpbnRmKCIlZCAiLCBtYXRbaV1bal0pOwogICAgIAkKICAgICAgICB9CQkKICAgICAgICAgICAgcHJpbnRmKCJcbiIpOwogICAgIH0gCQp9CgoKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIgY29uc3QgKmFyZ3ZbXSkKewoKCWludCBtYXRyaXhbU0laRV1bU0laRV0sCgoJICAgbm9kZXMsIGVkZ2VzLCBzLCBpLCBqOwoKICAgIHNjYW5mKCIlZCAlZCIsICZub2RlcywgJmVkZ2VzKTsKCiAgICB3aGlsZShlZGdlcy0tKSB7CgogICAgICAgICBzY2FuZigiJWQgJWQiLCAmaSwgJmopOwoKICAgICAgICAgbWF0cml4W2ldW2pdID0gMTsgICAgICAgICAgICAgICAgICAKICAgIH0KCiAgICBkaXNwbGF5KG1hdHJpeCwgbm9kZXMpOwoKICAgIGJmcyhtYXRyaXgsIG5vZGVzLCA0KTsgICAgCgkKCXJldHVybiAwOwp9