Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while(!q.empty()) {
- int cur = q.front();
- q.pop();
- for(int i = 0; i < n; i++) {
- if(a[cur][i] != -1) {
- d[i] = min(d[i], d[cur] + a[cur][i]);
- if(!used[i]) {
- d[i] = min(d[i], d[cur] + a[cur][i]);
- q.push(i);
- used[i] = 1;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement