Submission #255408

#TimeUsernameProblemLanguageResultExecution timeMemory
255408tleontest1Commuter Pass (JOI18_commuter_pass)C++17
31 / 100
514 ms42720 KiB
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #pragma GCC optimize ("unroll-loops") #pragma GCC target ("avx2") #include <bits/stdc++.h> using namespace std; typedef long long lo; typedef pair< lo,lo > PII; #define fi first #define se second #define mp make_pair #define int long long #define endl "\n" #define pb push_back #define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR for(int i=1;i<=n;i++) #define mid ((start+end)/2) #define ort ((bas+son)/2) const lo inf = 1000000000000000000; const lo KOK = 100000; const lo LOG = 30; const lo li = 500005; const lo mod = 1000000007; int n,m,b[li],a[li],k,flag,t,u,v,s,visit[li],d[li],vis[li]; int cev; vector<PII> vec[li]; inline void sp(){ priority_queue<PII> pq; pq.push({0,t}); while(pq.size()){ int node=pq.top().se; int co=-pq.top().fi; pq.pop(); if(vis[node])continue; vis[node]=1; d[node]=co; for(int i=0;i<(int)vec[node].size();i++){ int go=vec[node][i].fi; int ind=vec[node][i].se; pq.push({-co-a[ind],go}); } } //~ cout<<d[s]<<endl; memset(vis,0,sizeof(vis)); pq.push({0,s}); while(pq.size()){ int node=pq.top().se; int co=-pq.top().fi; pq.pop(); if(vis[node])continue; vis[node]=1; for(int i=0;i<(int)vec[node].size();i++){ int go=vec[node][i].fi; int ind=vec[node][i].se; //~ cout<<go<<" : : "<<co<<" : : "<<d[go]<<" : : "<<a[ind]<<endl; if(d[go]+co+a[ind]==d[s])visit[ind]=1; pq.push({-co-a[ind],go}); } } memset(vis,0,sizeof(vis)); priority_queue<PII> pq1; pq1.push({0,u}); while(pq1.size()){ int node=pq1.top().se; int co=-pq1.top().fi; pq1.pop(); if(vis[node])continue; vis[node]=1; if(node==v){printf("%lld\n",co);exit(0);} for(int i=0;i<(int)vec[node].size();i++){ int go=vec[node][i].fi; int ind=vec[node][i].se; int coo=co; if(visit[ind]==0)coo+=a[ind]; //~ cout<<visit[ind]<<" () "<<ind<<endl; pq1.push({-coo,go}); } } } main(void){ scanf("%lld %lld",&n,&m); scanf("%lld %lld",&s,&t); scanf("%lld %lld",&u,&v); for(int i=1;i<=m;i++){ int x,y; scanf("%lld %lld %lld",&x,&y,&a[i]); vec[x].pb({y,i}); vec[y].pb({x,i}); } sp(); return 0; }

Compilation message (stderr)

commuter_pass.cpp:89:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(void){
          ^
commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:90:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:91:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&s,&t);
  ~~~~~^~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:92:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&u,&v);
  ~~~~~^~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:95:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld",&x,&y,&a[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...