#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <ctype.h>
#include <stdlib.h>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
using namespace std;
int n,m,k,used[100005],d[100005];
vector<pair<int, int>> g[100005];
priority_queue<pair<int, int>> q;
int main()
{
cin >> n >> m;
for (int i = 0; i < m; i++)
{
int a, b,D;
pair<int, int> s;
cin >> a >> b >> D;
s.second = D;
s.first = b;
g[a].PB(s);
s.first = a;
g[b].PB(s);
}
for (int i = 1; i <= n; i++)
d[i] = mod;
cin >> k;
for (int i = 0; i < k; i++)
{
int a;
cin >> a;
d[a] = 0ll;
pair<int, int> s;
s.second = a;
s.first = -d[a];
q.push(s);
}
for (!q.empty())
{
int v=-1;
do
{
v = q.top().second;
q.pop();
} while (used[v] && !q.empty());
if (v == -1 || used[v])
break;
used[v] = 1;
for (int i = 0; i < (int)g[v].size(); i++)
{
int to = g[v][i].first;
if (d[to] > d[v] + g[v][i].second)
{
d[to] = d[v] + g[v][i].second;
pair<int, int> s;
s.first = -d[to];
s.second = to;
q.push(s);
}
}
}
//for (int i=1;i<=n;i++)cout<<d[i]<<" ";
cin >> k;
for (int i = 0; i < k; i++)
{
int a, b;
cin >> a >> b;
cout << min(d[a], d[b]) << endl;
}
return 0;
}
Compilation message
plan.cpp: In function 'int main()':
plan.cpp:56:17: error: expected ';' before ')' token
for (!q.empty())
^
plan.cpp:83:2: error: expected primary-expression before 'for'
for (int i = 0; i < k; i++)
^~~
plan.cpp:83:2: error: expected ')' before 'for'