Language: C++

#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, m , l;
const int inf = 1e9 + 7;
int ans[305][305];
bool vis[305];
vector<pair<int,int>> a[maxn];
using pii = pair<int,int>;
#define mp make_pair
bool cmp(const pii & x, const pii &y){
    if(x.first == y.first) return x.second > y.second;
    return x.first < y.first;
}
pair<int,int> dp[305];
struct S{
    int nod, cnt, val;
};

void greedy(int start){
    priority_queue<S> q;
    for(int i = 1 ;i <= n + 1;i ++){
        dp[i] = mp(inf , -inf);
        vis[i] = false;
    }
    dp[start] = make_pair(0 , l);
    q.push(S(start, 0 , l));
    while(!q.empty()){
        auto p = q.top();
        q.pop();
        if(vis[p.nod]) continue;
        for(auto i:a[p.nod]){
            if(!vis[i.first] && p.val >= i.second && cmp(mp(p.cnt,p.val - i.second), dp[i.first])){
                q.push(S(i.first, p.cnt, p.val - i.second));
                dp[i.first] = mp(p.cnt, p.val - i.second);
            }
            else if(!vis[i.first] && p.val < i.second && cmp(mp(p.cnt + 1, l - i.second) , dp[i.first])){
                q.push(S(i.first, p.cnt + 1 , l - i.second));
                dp[i.first] = mp(p.cnt + 1, l  - i.second);
            }
        }
    }
    for(int i = 1 ;i <= n;i ++){
        if(i != start){
            if(dp[i] != mp(inf,-inf)){
                ans[start][i] = dp[i].first;
            }
            else ans[start][i] = -1;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> m >> l;
    while(m -- ){
        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 = 1 ;i<= n;i++){
        greedy(i);
    }
    int q,x,y;
    cin >> q;
    while(q -- ){
        cin >> x >> y;
        cout <<ans[x][y] << '\n';
    }
}
/*
    Good Luck
        -Lucina
*/


Compiler output:
a.cc: In function 'void greedy(int)':
a.cc:27:26: error: no matching function for call to 'S::S(int&, int, int&)'
   27 |     q.push(S(start, 0 , l));
      |                          ^
a.cc:16:8: note: candidate: 'S::S()'
   16 | struct S{
      |        ^
a.cc:16:8: note:   candidate expects 0 arguments, 3 provided
a.cc:16:8: note: candidate: 'constexpr S::S(const S&)'
a.cc:16:8: note:   candidate expects 1 argument, 3 provided
a.cc:16:8: note: candidate: 'constexpr S::S(S&&)'
a.cc:16:8: note:   candidate expects 1 argument, 3 provided
a.cc:34:58: error: no matching function for call to 'S::S(int&, int&, int)'
   34 |                 q.push(S(i.first, p.cnt, p.val - i.second));
      |                                                          ^
a.cc:16:8: note: candidate: 'S::S()'
   16 | struct S{
      |        ^
a.cc:16:8: note:   candidate expects 0 arguments, 3 provided
a.cc:16:8: note: candidate: 'constexpr S::S(const S&)'
a.cc:16:8: note:   candidate expects 1 argument, 3 provided
a.cc:16:8: note: candidate: 'constexpr S::S(S&&)'
a.cc:16:8: note:   candidate expects 1 argument, 3 provided
a.cc:38:59: error: no matching function for call to 'S::S(int&, int, int)'
   38 |                 q.push(S(i.first, p.cnt + 1 , l - i.second));
      |                                                           ^
a.cc:16:8: note: candidate: 'S::S()'
   16 | struct S{
      |        ^
a.cc:16:8: note:   candidate expects 0 arguments, 3 provided
a.cc:16:8: note: candidate: 'constexpr S::S(const S&)'
a.cc:16:8: note:   candidate expects 1 argument, 3 provided
a.cc:16:8: note: candidate: 'constexpr S::S(S&&)'
a.cc:16:8: note:   candidate expects 1 argument, 3 provided
In file included from /usr/include/c++/14/string:49,
                 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/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = S]':
/usr/include/c++/14/bits/predefined_ops.h:158:30:   required from 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<S*, std::vector<S, std::allocator<S> > >; _Iterator2 = __gnu_cxx::__normal_iterator<S*, std::vector<S, std::allocator<S> > >; _Compare = std::less<S>]'
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:232:14:   required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<S*, vector<S, allocator<S> > >; _Distance = long int; _Tp = S; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<less<S> >]'
  232 |           if (__comp(__first + __secondChild,
      |               ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
  233 |                      __first + (__secondChild - 1)))
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:264:25:   required from 'void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<S*, vector<S, allocator<S> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<less<S> >]'
  264 |       std::__adjust_heap(__first, _DistanceType(0),
      |       ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
  265 |                          _DistanceType(__last - __first),
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  266 |                          _GLIBCXX_MOVE(__value), __comp);
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:333:19:   required from 'void std::pop_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<S*, vector<S, allocator<S> > >; _Compare = less<S>]'
  333 |           std::__pop_heap(__first, __last, __last, __cmp);
      |           ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:774:15:   required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::pop() [with _Tp = S; _Sequence = std::vector<S, std::allocator<S> >; _Compare = std::less<S>]'
  774 |         std::pop_heap(c.begin(), c.end(), comp);
      |         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:30:14:   required from here
   30 |         q.pop();
      |         ~~~~~^~
/usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const S' and 'const S')
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
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:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1045 |     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const S' is not derived from 'const std::pair<_T1, _T2>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  448 |     operator<(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const S' is not derived from 'const std::reverse_iterator<_Iterator>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  493 |     operator<(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const S' is not derived from 'const std::reverse_iterator<_Iterator>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1694 |     operator<(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const S' is not derived from 'const std::move_iterator<_IteratorL>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1760 |     operator<(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const S' is not derived from 'const std::move_iterator<_IteratorL>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~