vector g[100001]; vector visi(100001,0); void bfs(ll v, ll n) { queue q; q.push(v); visi[v] = 1; dist[v] = 0; ll level = 1; while (!q.empty()) { ll node = q.front(); q.pop(); cout << node << " "; for (ll child : g[node]) { if (visi[child] == 0) { q.push(child); visi[child] = 1; } } } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter