Submission #170703

#TimeUsernameProblemLanguageResultExecution timeMemory
170703juggernautEvacuation plan (IZhO18_plan)C++14
0 / 100
4041 ms16040 KiB
//Just try and the idea will come! #include<bits/stdc++.h> #define int long long int using namespace std; int n,m,i,x,y,z,mn[100001],e,res,path[100001],vis[100001],mx; vector<vector<pair<int,int>>>g(100001); void update(int v){ for(auto to:g[v]){ if(mn[v]+to.second<mn[to.first]){ mn[to.first]=mn[v]+to.second; update(to.first); } } } bool dfs(int v){ path[e++]=v; vis[v]=1; if(v==y){ res=1e15; for(i=1;i<e;i++)res=min(res,mn[path[i]]); mx=max(mx,res); vis[v]=0; e--; return true; } for(auto to:g[v]){ if(!vis[to.first]&&!dfs(to.first))return true; } vis[v]=0; e--; return false; } main(){ scanf("%lld%lld",&n,&m); for(i=1;i<=n;i++)mn[i]=1e15; while(m--){ scanf("%lld%lld%lld",&x,&y,&z); g[x].push_back({y,z}); g[y].push_back({x,z}); } scanf("%lld",&m); while(m--){ scanf("%lld",&x); mn[x]=0; update(x); } scanf("%lld",&m); while(m--){ scanf("%lld%lld",&x,&y); for(i=1;i<=n;i++)vis[i]=0; e=1;mx=0; dfs(x); printf("%lld\n",mx); } }

Compilation message (stderr)

plan.cpp:33:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
plan.cpp: In function 'int main()':
plan.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~~~~
plan.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld%lld",&x,&y,&z);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
plan.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&m);
     ~~~~~^~~~~~~~~~~
plan.cpp:43:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&x);
         ~~~~~^~~~~~~~~~~
plan.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&m);
     ~~~~~^~~~~~~~~~~
plan.cpp:49:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld",&x,&y);
         ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...