Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- queue<int> q;
- q.push(s); dist[s]=0;
- while (q.size()){
- int now=q.front(); q.pop();
- for (int nex:G[now]) if (dist[nex]==-1) {
- dist[nex]=dist[now]+1;
- q.push(nex);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement