Submission #490309

#TimeUsernameProblemLanguageResultExecution timeMemory
490309SirCovidThe19th007 (CEOI14_007)C++17
0 / 100
406 ms22724 KiB
#include <bits/stdc++.h> using namespace std; const int mx = 2e5 + 5; int n, m, s, v, a, b, ds[mx], dd[mx], da[mx], db[mx]; vector<int> adj[mx]; int bfs(int st, int en){ queue<int> Q; int D[n + 1]; fill(D, D + n + 1, -1); Q.push(st); D[st] = 0; while (!Q.empty()){ int i = Q.front(); Q.pop(); if (i == en) return D[i]; for (int j : adj[i]) if (D[j] == -1) D[j] = D[i] + 1, Q.push(j); } } int main(){ cin >> n >> m >> s >> v >> a >> b; for (int i = 1; i <= m; i++){ int a, b; cin >> a >> b; adj[a].push_back(b); adj[b].push_back(a); } cout<<max(min(bfs(v, a) - bfs(s, a), bfs(v, b) - bfs(s, b)), -1)<<endl; }

Compilation message (stderr)

007.cpp: In function 'int bfs(int, int)':
007.cpp:9:16: warning: control reaches end of non-void function [-Wreturn-type]
    9 |     queue<int> Q; int D[n + 1]; fill(D, D + n + 1, -1);
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...