Language: C++

#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int>>A[301];
pair<int,int> dp[301][301];
void djkstra(int i){
  priority_queue<pair<pair<int,int>,int>,vector<pair<int,int>>,greater <pair<int,int>>> pq;
  pq.push_back({0,i});
  int V[n+1] = {0};
  dp[i][i] = 0;
  while(!pq.empty()){
    auto x = pq.top();
    pq.pop();
    V[x.second] = 1
    for(int k = 0 ; k < A[x.second].size(); k ++){
      if(V[A[x][k].first])continue;
      if(dp[i][A[x.second][k].first].first > dp[i][x.second].first + (x.first.second < A[x.second][k].second ? 1 : 0)){
      	pq.erase({{dp[i][A[x.second][k].first].first,dp[i][A[x.second][k].first].second},A[x.second][k].first});
        pq.insert({{dp[i][x.second].first + (x.second < A[x.second][k].second ? 1 : 0),x.first.second - A[x.second][k].second + (x.first.second < A[x.second][k].second ? l : 0)},A[x.second][k].first);
      }
      if(dp[i][A[x.second][k].first].first == dp[i][x.second].first + (x.first.second < A[x.second][k].second ? 1 : 0)){
      	if(dp[i][A[x.second][k].first].second < x.first.second - A[x.second][k].second + (x.first.second < A[x.second][k].second ? l : 0)){
        	pq.erase({{dp[i][A[x.second][k].first].first,dp[i][A[x.second][k].first].second},A[x.second][k].first});
        	pq.insert({{dp[i][x.second].first + (x.second < A[x.second][k].second ? 1 : 0),x.first.second - A[x.second][k].second + (x.first.second < A[x.second][k].second ? l : 0)},A[x.second][k].first);
        }
      }            
    }
  }
    
}
int main(){
  int n,m,l;
  cin>>n>>m>>l;
  for(int i = 0 ; i < m ; i++){
    int x,y,z;
    cin>>x>>y>>z;
    if(z > l)continue;
    A[x].push_back({y,z});
    A[y].push_back({x,z});
  }
  for(int i = 0 ; i <= n ; i ++){
    for(int j = 0 ; j <= n ; j ++)dp[i][j].first = LLONG_MAX;
  }
  
  for(int i = 1 ; i <= n ; i ++)djkstra(i);
  int q;
  cin>>q;
  while(q--){
  	int x,y;
    cin>>x>>y;
    if(dp[x][y].first == LLONG_MAX)cout<<-1<<endl;
    else cout<<dp[x][y].first<<endl;
  }
  
}

Compiler output:
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h: In instantiation of 'class std::priority_queue<std::pair<std::pair<int, int>, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >':
a.cc:6:89:   required from here
    6 |   priority_queue<pair<pair<int,int>,int>,vector<pair<int,int>>,greater <pair<int,int>>> pq;
      |                                                                                         ^~
/usr/include/c++/14/bits/stl_queue.h:520:67: error: static assertion failed: value_type must be the same as the underlying container
  520 |       static_assert(is_same<_Tp, typename _Sequence::value_type>::value,
      |                                                                   ^~~~~
/usr/include/c++/14/bits/stl_queue.h:520:67: note: 'std::integral_constant<bool, false>::value' evaluates to false
a.cc: In function 'void djkstra(int)':
a.cc:7:6: error: 'class std::priority_queue<std::pair<std::pair<int, int>, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >' has no member named 'push_back'
    7 |   pq.push_back({0,i});
      |      ^~~~~~~~~
a.cc:8:9: error: 'n' was not declared in this scope
    8 |   int V[n+1] = {0};
      |         ^
a.cc:9:14: error: no match for 'operator=' (operand types are 'std::pair<int, int>' and 'int')
    9 |   dp[i][i] = 0;
      |              ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:946:9: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U2 = _U1; _T1 = int; _T2 = int]'
  946 |         operator=(const pair<_U1, _U2>& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:946:9: note:   template argument deduction/substitution failed:
a.cc:9:14: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
    9 |   dp[i][i] = 0;
      |              ^
/usr/include/c++/14/bits/stl_pair.h:957:9: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U2 = _U1; _T1 = int; _T2 = int]'
  957 |         operator=(pair<_U1, _U2>&& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:957:9: note:   template argument deduction/substitution failed:
a.cc:9:14: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
    9 |   dp[i][i] = 0;
      |              ^
/usr/include/c++/14/bits/stl_pair.h:921:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::__conditional_t<((bool)std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value), const std::pair<_T1, _T2>&, const std::__nonesuch&>) [with _T1 = int; _T2 = int; std::__conditional_t<((bool)std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value), const std::pair<_T1, _T2>&, const std::__nonesuch&> = const std::pair<int, int>&]'
  921 |       operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:923:65: note:   no known conversion for argument 1 from 'int' to 'std::__conditional_t<true, const std::pair<int, int>&, const std::__nonesuch&>' {aka 'const std::pair<int, int>&'}
  921 |       operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
  922 |                                        is_copy_assignable<_T2>>::value,
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  923 |                                 const pair&, const __nonesuch&> __p)
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_pair.h:931:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::__conditional_t<((bool)std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value), std::pair<_T1, _T2>&&, std::__nonesuch&&>) [with _T1 = int; _T2 = int; std::__conditional_t<((bool)std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value), std::pair<_T1, _T2>&&, std::__nonesuch&&> = std::pair<int, int>&&]'
  931 |       operator=(__conditional_t<__and_<is_move_assignable<_T1>,
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:933:55: note:   no known conversion for argument 1 from 'int' to 'std::__conditional_t<true, std::pair<int, int>&&, std::__nonesuch&&>' {aka 'std::pair<int, int>&&'}
  931 |       operator=(__conditional_t<__and_<is_move_assignable<_T1>,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  932 |                                        is_move_assignable<_T2>>::value,
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  933 |                                 pair&&, __nonesuch&&> __p)
      |                                 ~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:13:5: error: 'V' was not declared in this scope
   13 |     V[x.second] = 1
      |     ^
a.cc:14:21: error: 'k' was not declared in this scope
   14 |     for(int k = 0 ; k < A[x.second].size(); k ++){
      |                     ^
a.cc:30:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   30 | int main(){
      |         ^~
a.cc:30:9: note: remove parentheses to default-initialize a variable
   30 | int main(){
      |         ^~
      |         --
a.cc:30:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:30:11: error: a function-definition is not allowed here before '{' token
   30 | int main(){
      |           ^
a.cc:54:2: error: expected '}' at end of input
   54 | }
      |  ^
a.cc:10:21: note: to match this '{'
   10 |   while(!pq.empty()){
      |                     ^
a.cc:54:2: error: expected '}' at end of input
   54 | }
      |  ^
a.cc:5:20: note: to match this '{'
    5 | void djkstra(int i){
      |                    ^