Submission #171522

#TimeUsernameProblemLanguageResultExecution timeMemory
171522TadijaSebez007 (CEOI14_007)C++11
0 / 100
320 ms23672 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back const int N=200050; vector<int> E[N]; void BFS(int x, int n, int d[]) { for(int i=1;i<=n;i++) d[i]=-1; queue<int> q; q.push(x); d[x]=0; while(q.size()) { int u=q.front(); q.pop(); for(int v:E[u]) if(d[v]==-1) { d[v]=d[u]+1; q.push(v); } } } int ds[N],dd[N]; int main() { int n,m,s,d,a,b; scanf("%i %i",&n,&m); scanf("%i %i %i %i",&s,&d,&a,&b); for(int i=1,u,v;i<=m;i++) scanf("%i %i",&u,&v),E[u].pb(v),E[v].pb(u); BFS(s,n,ds); BFS(d,n,dd); //printf("%i %i %i %i\n",ds[a],ds[b],dd[a],dd[b]); int ans=min(dd[a]-ds[a],dd[b]-ds[b]); ans=max(ans,-1); printf("%i\n",ans); return 0; }

Compilation message (stderr)

007.cpp: In function 'int main()':
007.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
007.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i %i %i",&s,&d,&a,&b);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
007.cpp:29:59: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1,u,v;i<=m;i++) scanf("%i %i",&u,&v),E[u].pb(v),E[v].pb(u);
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...