This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n,q;
int m;
vector<pair<int,int>>g[100005];
long long d[100005];
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});
    }
    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;
        cout<<min(d[s],d[t])<<'\n';
    }
    return 0;
}
Compilation message (stderr)
plan.cpp: In function 'int main()':
plan.cpp:29:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |         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... |