Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);

  int N,M,L; cin>>N>>M>>L;
  vector<pair<int, int>> graph[N];
  for (int i = 0; i < M; i++) {
    int a,b,c; cin>>a>>b>>c;
    if (c <= L) {
	  graph[--a].emplace_back(--b, c);
	  graph[b].emplace_back(a, c);
    }
  }
  struct ExpInfo {
    int id;
	int cnt;
    int gas;
    bool operator<(const ExpInfo& x) const {return cnt != x.cnt ? cnt > x.cnt : gas < x.gas;}
  };

  vector<ExpInfo> infos(N);
  for (int i = 0; i < N; i++) {
    auto& info = infos[i];
	for (int i = 0; i < N; i++) {
	  info[i] = {i, numeric_limits<int>::max(), 0};
	}
	info[s] = {s,0,L};
	priority_queue<ExpInfo> qs;
	qs.push(info[s]);
	while (not qs.empty()) {
	  auto q = qs.top(); qs.pop();
	  if (q < info[q.id])
		continue;
	  for (auto &path : graph[q.id]) {
		auto c = info[q.id];
		if (c.gas < path.second) {
		  c.cnt++;
		  c.gas = L;
		}
		c.gas -= path.second;
		if (info[path.first] < c) {
		  info[path.first] = c;
		  info[path.first].id = path.first;
		  qs.push(info[path.first]);
		}
	  }
	}
  }
  
  int Q; cin>>Q;
  while (Q--) {
    int s,t; cin>>s>>t;
    s--; t--;

    if (infos[s][t].cnt == numeric_limits<int>::max())
      cout << -1 << endl;
	else
	  cout << infos[s][t].cnt << endl;
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:15: error: no match for 'operator[]' (operand types are 'main()::ExpInfo' and 'int')
   28 |           info[i] = {i, numeric_limits<int>::max(), 0};
      |               ^
a.cc:30:14: error: 's' was not declared in this scope
   30 |         info[s] = {s,0,L};
      |              ^
a.cc:35:23: error: no match for 'operator[]' (operand types are 'main()::ExpInfo' and 'int')
   35 |           if (q < info[q.id])
      |                       ^
a.cc:38:30: error: no match for 'operator[]' (operand types are 'main()::ExpInfo' and 'int')
   38 |                 auto c = info[q.id];
      |                              ^
a.cc:44:25: error: no match for 'operator[]' (operand types are 'main()::ExpInfo' and 'int')
   44 |                 if (info[path.first] < c) {
      |                         ^
a.cc:45:23: error: no match for 'operator[]' (operand types are 'main()::ExpInfo' and 'int')
   45 |                   info[path.first] = c;
      |                       ^
a.cc:46:23: error: no match for 'operator[]' (operand types are 'main()::ExpInfo' and 'int')
   46 |                   info[path.first].id = path.first;
      |                       ^
a.cc:47:31: error: no match for 'operator[]' (operand types are 'main()::ExpInfo' and 'int')
   47 |                   qs.push(info[path.first]);
      |                               ^
a.cc:58:17: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<main()::ExpInfo>, main()::ExpInfo>::value_type' {aka 'main()::ExpInfo'} and 'int')
   58 |     if (infos[s][t].cnt == numeric_limits<int>::max())
      |                 ^
a.cc:61:27: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<main()::ExpInfo>, main()::ExpInfo>::value_type' {aka 'main()::ExpInfo'} and 'int')
   61 |           cout << infos[s][t].cnt << endl;
      |                           ^