1#include <bits/stdc++.h>
2using namespace std;
3
4vector<int> bfs(const vector<vector<int>>& g, int start) {
5 vector<int> order; vector<bool> seen(g.size(), false);
6 queue<int> q; q.push(start); seen[start] = true;
7 while (!q.empty()) {
8 int u = q.front(); q.pop();
9 order.push_back(u);
10 for (int v : g[u]) if (!seen[v]) { seen[v] = true; q.push(v); }
11 }
12 return order;
13}