이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |