Submission #29917

#TimeUsernameProblemLanguageResultExecution timeMemory
29917PrOAhMeT007 (CEOI14_007)C++14
0 / 100
363 ms18168 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define pii pair<int,int> #define LL long long #define st first #define nd second #define endl '\n' using namespace std; const int MAXN=200005; int n,m,dis[2][MAXN],s,d,a,b,t,tt; vector<int> v[MAXN]; void bfs(int start,int wait,int u) { memset(dis[u],-1,sizeof dis[u]); queue<int> q; dis[u][start]=0; int x,y; q.push(start); while(!q.empty()) { x=q.front(); q.pop(); for(int i=0;i<v[x].size();++i) { y=v[x][i]; if(dis[u][y]==-1) { dis[u][y]=dis[u][x]+1; q.push(y); } } } } int main() { scanf("%d %d",&n,&m); scanf("%d %d %d %d",&s,&d,&a,&b); for(int i=0;i<m;++i) { scanf("%d %d",&t,&tt); v[t].pb(tt); v[tt].pb(t); } int l=0,r=n,ans=-1,md; bfs(d,0,1); bfs(s,0,0); if(dis[0][a]>dis[1][a]||dis[0][b]>dis[1][b]) cout<<-1<<endl; else { cout<<min(dis[1][a]-dis[0][a],dis[1][b]-dis[0][b])<<endl; } }

Compilation message (stderr)

007.cpp: In function 'void bfs(int, int, int)':
007.cpp:25:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<v[x].size();++i) {
                ^
007.cpp: In function 'int main()':
007.cpp:45:6: warning: unused variable 'l' [-Wunused-variable]
  int l=0,r=n,ans=-1,md;
      ^
007.cpp:45:10: warning: unused variable 'r' [-Wunused-variable]
  int l=0,r=n,ans=-1,md;
          ^
007.cpp:45:14: warning: unused variable 'ans' [-Wunused-variable]
  int l=0,r=n,ans=-1,md;
              ^
007.cpp:45:21: warning: unused variable 'md' [-Wunused-variable]
  int l=0,r=n,ans=-1,md;
                     ^
007.cpp:38:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
                      ^
007.cpp:39:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d %d",&s,&d,&a,&b);
                                  ^
007.cpp:41:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&t,&tt);
                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...