Language: C++

#include <stdio.h>
#include <string.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<string.h>
#include<functional>
#define int long long
#define P pair<int,int>
using namespace std;

int mincost[100000];
vector<P>rinsetu[100000];
struct E {
	int first, second, ID;
};
struct F {
	int cost, v, u;
};
bool operator <(E a, E b) {
	if (a.first != b.first)return a.first < b.first;
	return a.ID < b.ID;
}
int p[100000];//par
int r[100000];//rank
int find(int a) {
	if (p[a] == a)return a;
	return find(p[a]);
}
void unite(int a,int b) {
	int c = find(a), d = find(b);
	if (c == d)return;
	if (r[c] > r[d]) {
		p[d] = c;
	}
	else if (r[c] < r[d]) {
		p[c] = d;
	}
	else {
		r[c]++;
		p[d] = c;
	}
}
F c[200000];//???
int x[100000], y[100000], z[100000];
E n[100000];//????????¢?´¢???(S,G]
signed main() {
	int M, Q;//????\????
	int a, b; scanf("%lld%lld%lld%lld", &a, &b, &M, &Q);
	priority_queue<P, vector<P>, greater<P>>q;
	for (int d = 0; d < b; d++) {
		scanf("%lld%lld", &c[d].v, &c[d].u);
		int U; scanf("%lld", &U);
		c[d].v--; c[d].u--;
		rinsetu[c[d].v].push_back({ U,c[d].u });
		rinsetu[c[d].u].push_back({ U,c[d].v });
	}
	memset(mincost, 0x3f, sizeof(mincost));
	for (int i = 0; i < M; i++) {
		int R; scanf("%lld", &R);
		R--;
		mincost[R] = 0;
		q.push({ 0,R });
	}
	while (q.size()) {
		P t = q.top(); q.pop();
		for (P i : rinsetu[t.second]) {
			if (mincost[i.second] > t.first + i.first) {
				mincost[i.second] = t.first + i.first;
				q.push({ mincost[i.second], i.second });
			}
		}
	}
	int count = 0;
	for (int i = 0; i < a; i++) {
		for (P j : rinsetu[i]) {
			if (i < j.second) {
				c[count++] = { min(mincost[i],mincost[j.second]),i,j.second };
			}
		}
	}
	sort(c, c + b, [](F a, F b) {if (a.cost != b.cost)return a.cost > b.cost; return a.v * 1000000 + a.u > b.v * 1000000 + b.u; });
	for (int i = 0; i < count; i++) {
		cout << c[i].cost << " " << c[i].v << " " << c[i].u << endl;
	}
	for (int i = 0; i < Q; i++) {
		scanf("%lld%lld", &x[i], &y[i]);
		x[i]--; y[i]--;
		n[i] = { 0,INT_MAX,i };
	}
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < a; j++) {//UF????????????
			p[j] = j;
			r[j] = 0;
		}
		sort(n, n + Q, [](E a, E b) {if (a.first != b.first)return a.first > b.first; return a.ID < b.ID; });
		int K = 0;
		for (int j = 0; j < Q; j++) {
			int T = (n[j].first + n[j].second) / 2;
			while (c[K].cost >= T&&K<b) {
				unite(c[K].u, c[K].v);
				K++;
			}
			if (find(x[n[j].ID])== find(y[n[j].ID])) {
				n[j].first = T;
			}
			else {
				n[j].second = T;
			}
		}
	}
	sort(n, n + Q, [](E a, E b) {return a.ID < b.ID; });
	for (int i = 0; i < Q; i++) {
		printf("%lld\n", n[i].first);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:93:28: error: 'INT_MAX' was not declared in this scope
   93 |                 n[i] = { 0,INT_MAX,i };
      |                            ^~~~~~~
a.cc:12:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include<functional>
  +++ |+#include <climits>
   12 | #define int long long
a.cc:93:38: error: no match for 'operator=' (operand types are 'E' and '<brace-enclosed initializer list>')
   93 |                 n[i] = { 0,INT_MAX,i };
      |                                      ^
a.cc:18:8: note: candidate: 'constexpr E& E::operator=(const E&)'
   18 | struct E {
      |        ^
a.cc:18:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const E&'
a.cc:18:8: note: candidate: 'constexpr E& E::operator=(E&&)'
a.cc:18:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'E&&'