fork download
  1. vector<int> dist(n, 1e9);
  2. queue<int> q;
  3. for (int i = 0; i < n; ++i)
  4. {
  5. if (arr[i] == "source")
  6. {
  7. dist[i] = 0;
  8. q.push(i);
  9. }
  10. }
  11.  
  12. while (q.size())
  13. {
  14. int x = q.front();
  15. q.pop();
  16. for (auto &i : adj[x])
  17. {
  18. if(dist[i] > dist[x] + 1)
  19. {
  20. q.push(i);
  21. dist[i] = dist[x] + 1;
  22. }
  23. }
  24. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:1: error: ‘vector’ does not name a type
 vector<int> dist(n, 1e9);
 ^~~~~~
prog.cpp:2:1: error: ‘queue’ does not name a type
 queue<int> q;
 ^~~~~
prog.cpp:3:1: error: expected unqualified-id before ‘for’
 for (int i = 0; i < n; ++i)
 ^~~
prog.cpp:3:17: error: ‘i’ does not name a type
 for (int i = 0; i < n; ++i)
                 ^
prog.cpp:3:24: error: expected unqualified-id before ‘++’ token
 for (int i = 0; i < n; ++i)
                        ^~
prog.cpp:12:1: error: expected unqualified-id before ‘while’
 while (q.size())
 ^~~~~
stdout
Standard output is empty