제출 #227101

#제출 시각아이디문제언어결과실행 시간메모리
227101Uzumaki_NaturooCommuter Pass (JOI18_commuter_pass)C++17
15 / 100
2089 ms15068 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,int i){ dis[i][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(dis[i][ch]<=dis[i][p]+cst) continue ; dis[i][ch] = dis[i][p]+cst ; pq.push({-dis[i][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}); } memset(dis,'?',sizeof dis); dijkstra(s,0) ; dijkstra(u,1) ; dijkstra(v,2) ; printf("%lld",min(dfs(t,dis[1][t],dis[2][t]) ,dis[1][v])) ; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:43: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:45: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...