Language: C++

#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll inf=1001001001;
ll n,m,l,q;

class CompareDist
{
public:
    bool operator()(pair<pair<ll,ll>,ll> n1,pair<pair<ll,ll>,ll> n2) {
        if(n1.first.first==n2.first.first) return n1.first.second>n2.first.second;
        return n1.first.first<n2.first.first;
    }
};

int main(){
    cin>>n>>m>>l;
    vector<vector<pair<ll,ll>>> route(n+1);
    vector<vector<ll>> is(n+1,vector<ll>(n+1,0));
    rep(i,m){
        ll a,b,c;
        cin>>a>>b>>c;
        if(c>l) continue;
        route[a].push_back({b,c}); route[b].push_back({a,c});
        is[a]=b; is[b]=a;
    }
    cin>>q;
    vector<vector<ll>> memo(n+1,vector<ll>(n+1,-10));
    rep(i, q){
        ll s,t; cin>>s>>t;
        if(memo[s][t]!=-10) {cout<<memo[s][t]<<endl; continue;}
        if(is[s][t]!=0) {cout<<0<<endl; memo[s][t]=0;}
        vector<pair<ll,ll>> cost(n+1,{inf,0});
        cost[s]={0,l};
        priority_queue<pair<pair<ll,ll>,ll>,vector<pair<pair<ll,ll>,ll>>,CompareDist> que;
        que.push({{0,l},s});
        while(!que.empty()){
            pair<pair<ll,ll>,ll> tmp=que.top();
            que.pop();
            int x=tmp.first.first,y=tmp.first.second,z=tmp.second;
            if(cost[z].first<x || (cost[z].first==x && cost[z].second>y)) continue;
            for(pair<ll,ll> j:route[z]){
                if(y>=j.second){
                    if(cost[j.first].first>x || (cost[j.first].first==x && cost[j.first].second<y-j.second)){
                        cost[j.first]={x,y-j.second};
                        que.push({{x,y-j.second},j.first});
                    }
                }else{
                    if(cost[j.first].first>x+1 || (cost[j.first].first==x+1 && cost[j.first].second<l-j.second)){
                        cost[j.first]={x+1,l-j.second};
                        que.push({{x+1,l-j.second},j.first});
                    }
                }
            }
        }
        rep(j,n+1){
            if(cost[j].first==inf) cost[j].first=-1;
            memo[s][j]=cost[j].first;
            memo[j][s]=cost[j].first;
        }
        cout<<cost[t].first<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:15: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'} and 'll' {aka 'long long int'})
   30 |         is[a]=b; is[b]=a;
      |               ^
In file included from /usr/include/c++/14/vector:72,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'const std::vector<long long int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'std::vector<long long int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'std::initializer_list<long long int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:30:24: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'} and 'll' {aka 'long long int'})
   30 |         is[a]=b; is[b]=a;
      |                        ^
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'const std::vector<long long int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'std::vector<long long int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'std::initializer_list<long long int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~