Language: C++

#include <bits/stdc++.h>

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

struct data {
	int place;
	int many;
	int gas;

	data(){};
	data(int p, int m, int g) :
		place(p),
		many(m),
		gas(g)
	{};

	bool operator>(const data &ri) const {
		return many == ri.many ?
			gas < ri.gas :
			many > ri.many;
	}
};

llong N, M, L, Q;
vector<vector<lpair>> edges;
vector<lpair> query;

llong solve(int start, int goal) {
	vector<vector<llong>> dis(N+1, vector<llong>(N+1, -inf));
	dis[start][0] = L;

	priority_queue<data, vector<data>, greater<data>> que;
	que.push(data(start, 0, L));
	while (que.size()) {
		data now = que.top();
		que.pop();
		if (dis[now.place][now.many] > now.gas) continue;
		if (now.place == goal) return now.first;
		for (auto edge: edges[now.place]) {
			if (now.gas >= edge.second) {
				data next(edge.first, now.many, now.gas - edge.second);
				if (next.many > 0) {
					if (dis[next.place][next.many-1] >= next.gas) continue;
				}
				if (dis[next.place][next.many] < next.gas) {
					dis[next.place][next.many] = next.gas;
					que.push(next);
				}
			}
			data next(edge.first, now.many + 1, L - edge.second);
			if (next.many == N) continue;
			if (dis[next.place][next.many-1] >= next.gas) continue;
			if (dis[next.place][next.many] < next.gas) {
				dis[next.place][next.many] = next.gas;
				que.push(next);
			}
		}
	}

	return -1;
}

int main() {
	cin >> N >> M >> L;

	edges.resize(N+1);
	llong a, b, c;
	for (int i = 0; i < M; ++i) {
		cin >> a >> b >> c;
		if (c > L) continue;
		edges[a].push_back(lpair(b, c));
		edges[b].push_back(lpair(a, c));
	}

	cin >> Q;
	query.resize(Q);
	for (int i = 0; i < Q; ++i) {
		cin >> query[i].first >> query[i].second;
	}

	for (auto q : query) {
		cout << solve(q.first, q.second) << endl;
	}

	return 0;
}


Compiler output:
a.cc: In function 'llong solve(int, int)':
a.cc:40:41: error: template argument 1 is invalid
   40 |         priority_queue<data, vector<data>, greater<data>> que;
      |                                         ^
a.cc:40:41: error: template argument 2 is invalid
a.cc:40:52: error: template argument 1 is invalid
   40 |         priority_queue<data, vector<data>, greater<data>> que;
      |                                                    ^~~~
a.cc:40:56: error: template argument 1 is invalid
   40 |         priority_queue<data, vector<data>, greater<data>> que;
      |                                                        ^~
a.cc:40:56: error: template argument 2 is invalid
a.cc:40:56: error: template argument 3 is invalid
a.cc:41:13: error: request for member 'push' in 'que', which is of non-class type 'int'
   41 |         que.push(data(start, 0, L));
      |             ^~~~
a.cc:41:18: error: reference to 'data' is ambiguous
   41 |         que.push(data(start, 0, L));
      |                  ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:13:8: note:                 'struct data'
   13 | struct data {
      |        ^~~~
a.cc:42:20: error: request for member 'size' in 'que', which is of non-class type 'int'
   42 |         while (que.size()) {
      |                    ^~~~
a.cc:43:17: error: reference to 'data' is ambiguous
   43 |                 data now = que.top();
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:13:8: note:                 'struct data'
   13 | struct data {
      |        ^~~~
a.cc:44:21: error: request for member 'pop' in 'que', which is of non-class type 'int'
   44 |                 que.pop();
      |                     ^~~
a.cc:45:25: error: 'now' was not declared in this scope; did you mean 'pow'?
   45 |                 if (dis[now.place][now.many] > now.gas) continue;
      |                         ^~~
      |                         pow
a.cc:46:21: error: 'now' was not declared in this scope; did you mean 'pow'?
   46 |                 if (now.place == goal) return now.first;
      |                     ^~~
      |                     pow
a.cc:47:39: error: 'now' was not declared in this scope; did you mean 'pow'?
   47 |                 for (auto edge: edges[now.place]) {
      |                                       ^~~
      |                                       pow
a.cc:49:33: error: reference to 'data' is ambiguous
   49 |                                 data next(edge.first, now.many, now.gas - edge.second);
      |                                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:13:8: note:                 'struct data'
   13 | struct data {
      |        ^~~~
a.cc:50:42: error: overloaded function with no contextual type information
   50 |                                 if (next.many > 0) {
      |                                          ^~~~
a.cc:51:54: error: overloaded function with no contextual type information
   51 |                                         if (dis[next.place][next.many-1] >= next.gas) continue;
      |                                                      ^~~~~
a.cc:51:66: error: overloaded function with no contextual type information
   51 |                                         if (dis[next.place][next.many-1] >= next.gas) continue;
      |                                                                  ^~~~
a.cc:51:82: error: overloaded function with no contextual type information
   51 |                                         if (dis[next.place][next.many-1] >= next.gas) continue;
      |                                                                                  ^~~
a.cc:53:46: error: overloaded function with no contextual type information
   53 |                                 if (dis[next.place][next.many] < next.gas) {
      |                                              ^~~~~
a.cc:53:58: error: overloaded function with no contextual type information
   53 |                                 if (dis[next.place][next.many] < next.gas) {
      |                                                          ^~~~
a.cc:53:71: error: overloaded function with no contextual type information
   53 |                                 if (dis[next.place][next.many] < next.gas) {
      |                                                                       ^~~
a.cc:54:50: error: overloaded function with no contextual type information
   54 |                                         dis[next.place][next.many] = next.gas;
      |                                                  ^~~~~
a.cc:54:62: error: overloaded function with no contextual type information
   54 |                                         dis[next.place][next.many] = next.gas;
      |                                                              ^~~~
a.cc:54:75: error: overloaded function with no contextual type information
   54 |                                         dis[next.place][next.many] = next.gas;
      |                                                                           ^~~
a.cc:55:45: error: request for member 'push' in 'que', which is of non-class type 'int'
   55 |                                         que.push(next);
      |                                             ^~~~
a.cc:58:25: error: reference to 'data' is ambiguous
   58 |                         data next(edge.first, now.many + 1, L - edge.second);
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:13:8: note:                 'struct data'
   13 | struct data {
      |        ^~~~
a.cc:59:34: error: overloaded function with no contextual type information
   59 |                         if (next.many == N) continue;
      |                                  ^~~~
a.cc:60:38: error: overloaded function with no contextual type information
   60 |                         if (dis[next.place][next.many-1] >= next.gas) continue;
      |                                      ^~~~~
a.cc:60:50: error: overloaded function with no contextual type information
   60 |                         if (dis[next.place][next.many-1] >= next.gas) continue;
      |                                                  ^~~~
a.cc:60:66: error: overloaded function with no contextual type information
   60 |                         if (dis[next.place][next.many-1] >= next.gas) continue;
      |                                                                  ^~~
a.cc:61:38: