Submission #246174

#TimeUsernameProblemLanguageResultExecution timeMemory
246174mieszko11b007 (CEOI14_007)C++14
30 / 100
303 ms23032 KiB
#include <bits/stdc++.h> using namespace std; int n, m; int s, d, a, b; vector<int> G[200007]; int dist[200007]; bool vis[200007]; void run_bfs(int w) { memset(vis, 0, sizeof vis); vis[w] = 1; dist[w] = 0; queue<int> Q; Q.push(w); while(!Q.empty()) { int u= Q.front(); Q.pop(); for(int v : G[u]) { if(!vis[v]) { vis[v] = 1; dist[v] = dist[u] + 1; Q.push(v); } } } } int main() { scanf("%d%d%d%d%d%d", &n, &m, &s, &d, &a, &b); while(m--) { int a, b; scanf("%d%d", &a, &b); G[a].push_back(b); G[b].push_back(a); } run_bfs(s); int sa = dist[a], sb = dist[b]; run_bfs(d); int da = dist[a], db = dist[b]; int val = min(da - sa, db - sb); if(val < 0) val = 0; printf("%d\n", val - 1); return 0; }

Compilation message (stderr)

007.cpp: In function 'int main()':
007.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d%d%d", &n, &m, &s, &d, &a, &b);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
007.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &a, &b);
   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...