제출 #851758

#제출 시각아이디문제언어결과실행 시간메모리
851758futureEvacuation plan (IZhO18_plan)C++14
35 / 100
4091 ms57776 KiB
#include <bits/stdc++.h> using namespace std; int n,q; int m; vector<pair<int,int>>g[100005]; long long d[100005]; long long dd[100005]; map<pair<int,int>,bool>ok; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m; while(m--) { int u,v,c; cin>>u>>v>>c; g[u].push_back({v,c}); g[v].push_back({u,c}); ok[ {u,v}]=1; } int k; cin>>k; for(int i=1; i<=n; i++)d[i]=1e18; priority_queue<pair<long long,int>,vector<pair<long long,int>>,greater<pair<long long,int>>>pq; while(k--) { int u; cin>>u; d[u]=0; pq.push({0,u}); } while(pq.size()) { auto[_,u]=pq.top(); pq.pop(); for(auto v:g[u])if(d[v.first]>d[u]+v.second) { d[v.first]=d[u]+v.second; pq.push({d[v.first],v.first}); } } int q; cin>>q; while(q--) { int s,t; cin>>s>>t; if(ok[ {s,t}]||ok[ {t,s}]) { cout<<min(d[s],d[t])<<'\n'; continue; } for(int i=1; i<=n; i++)dd[i]=-1e18; dd[s]=d[s]; pq.push({dd[s],s}); while(pq.size()) { auto[_,u]=pq.top(); pq.pop(); for(auto v:g[u])if(dd[v.first]<min(dd[u],d[v.first])) { dd[v.first]=min(dd[u],d[v.first]); pq.push({dd[v.first],v.first}); } } cout<<dd[t]<<'\n'; } return 0; }

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

plan.cpp: In function 'int main()':
plan.cpp:32:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   32 |         auto[_,u]=pq.top();
      |             ^
plan.cpp:52:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   52 |             auto[_,u]=pq.top();
      |                 ^
#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...