Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.17 KB | None | 0 0
  1. queue<int> q;
  2. q.push(s); dist[s]=0;
  3. while (q.size()){
  4.     int now=q.front(); q.pop();
  5.     for (int nex:G[now]) if (dist[nex]==-1) {
  6.         dist[nex]=dist[now]+1;
  7.         q.push(nex);
  8.     }
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement