fork download
  1. /*
  2.  * GSJANC
  3.  * Author: Omkar Prabhu <omkar.prabhu15@siesgst.ac.in>
  4.  */
  5. #include <bits/stdc++.h>
  6.  
  7. using namespace std;
  8.  
  9. #define MAX 12345
  10.  
  11. int visited[MAX];
  12. int dist[MAX];
  13. vector<int> v[MAX+1];
  14.  
  15. void bfs(int s, int e, int n)
  16. {
  17. for (int i = 0; i <= n; i++) { visited[i] = 0; dist[i] = 0; }
  18. visited[s] = 1;
  19. queue<int> q;
  20. q.push(s);
  21. while (!q.empty()) {
  22. int x = q.front(); q.pop();
  23. for (int i = 0; i < v[x].size(); i++) {
  24. if (visited[v[x][i]] == 0) {
  25. dist[v[x][i]] = dist[x]+1;
  26. visited[v[x][i]] = 1;
  27. q.push(v[x][i]);
  28. }
  29. }
  30. }
  31. }
  32.  
  33. int main()
  34. {
  35. ios_base::sync_with_stdio(0);
  36. // Start Solution here
  37. int t, n, m, s, e, a, b;
  38. cin >> t;
  39. while (t--) {
  40. cin >> n >> m >> s >> e;
  41. for (int i = 0; i <= n; i++) v[i].clear();
  42. for (int tt = 0; tt < m; tt++) {
  43. cin >> a >> b;
  44. v[a].push_back(b);
  45. v[b].push_back(a);
  46. }
  47. bfs(s, e, n);
  48. if (dist[e] == 0) cout << "NO" << endl;
  49. else cout << "YES " << (dist[e]-1) << endl;
  50. }
  51. // End Solution here
  52. return 0;
  53. } #include <iostream>
  54. using namespace std;
  55.  
  56. int main() {
  57. // your code goes here
  58. return 0;
  59. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:53:3: error: stray ‘#’ in program
 } #include <iostream>
   ^
prog.cpp:53:4: error: ‘include’ does not name a type
 } #include <iostream>
    ^~~~~~~
prog.cpp: In function ‘int main()’:
prog.cpp:56:5: error: redefinition of ‘int main()’
 int main() {
     ^~~~
prog.cpp:33:5: note: ‘int main()’ previously defined here
 int main()
     ^~~~
stdout
Standard output is empty