Submission #227100

#TimeUsernameProblemLanguageResultExecution timeMemory
227100Uzumaki_NaturooCommuter Pass (JOI18_commuter_pass)C++14
15 / 100
2092 ms17736 KiB
/// You just can't beat the person who never gives up /// ICPC next year #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include<bits/stdc++.h> using namespace std ; const int N = 1e5+5 ; int n ,m ,s ,t ,u ,v ,a ,b ,c ; vector<pair<int,int>> adj[N] ; long long dis[3][N] ; void dijkstra(int src,long long d[]){ for(int i=0;i<N;++i) d[i] = 1e18 ; d[src] = 0 ; priority_queue<pair<long long,int>> pq ; pq.push({0,src}); while(pq.size()){ int p = pq.top().second ; pq.pop() ; for(auto e:adj[p]){ int ch = e.first ; int cst = e.second ; if(d[ch]<=d[p]+cst) continue ; d[ch] = d[p]+cst ; pq.push({-d[ch],ch}); } } } long long dfs(int p,long long a,long long b){ long long ret = a + b ; for(auto e:adj[p]){ int ch = e.first ; int cst = e.second ; if(dis[0][ch]!=dis[0][p]-cst) continue ; long long aa = min(a ,dis[1][ch]) ; long long bb = min(b ,dis[2][ch]) ; ret = min(ret ,dfs(ch,aa,bb)) ; } return ret ; } int main(){ scanf("%d%d%d%d%d%d",&n,&m,&s,&t,&u,&v); while(m--){ scanf("%d%d%d",&a,&b,&c); adj[a].push_back({b,c}); adj[b].push_back({a,c}); } dijkstra(s,dis[0]) ; dijkstra(u,dis[1]) ; dijkstra(v,dis[2]) ; printf("%lld",min(dfs(t,dis[1][t],dis[2][t]) ,dis[1][v])) ; return 0; }

Compilation message (stderr)

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:44:10: 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,&t,&u,&v);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&a,&b,&c);
         ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...