Language: C++

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;

vvll cost_table(vll s,vll t,vll c,ll N){
    vvll ret(N,vll(N,INT_MAX));
    
    for(int i=0;i<N;i++) ret[i][i]=0;
    
    for(int i=0;i<t.size();i++){
        ret[s[i]][t[i]]=c[i];
        ret[t[i]][s[i]]=c[i];
    }
    
    return ret;
}

void warshall_floyd(vvll &cost){
    for(int k=0;k<cost.size();k++){
        for(int i=0;i<cost.size();i++){
            for(int j=0;j<cost.size();j++){
                cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
            }
        }
    }
}

void show_table(vvll d){
    if(d.size()==0) return;
    
    printf("  ");
    for(int i=0;i<d[0].size();i++) printf("%d,",i+1);
    printf("\n");
    
    for(int i=0;i<d.size();i++){
        printf("%d:",i+1);
        for(int j=0;j<d[i].size();j++){
            if(d[i][j]>INT_MAX*0.9) printf("M|");
            else printf("%lld|",d[i][j]);
        }
        printf("\n");
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M,L;
    cin>>N>>M>>L;
    vll A(M),B(M),C(M);
    for(int i=0;i<M;i++) {
        cin>>A[i]>>B[i]>>C[i];
        A[i]--;B[i]--;
    }
    
    ll Q;
    cin>>Q;
    vll s(Q),t(Q);
    for(int i=0;i<Q;i++) {
        cin>>s[i]>>t[i];
        s[i]--;t[i]--;
    }
    
    vvll cost=cost_table(A,B,C,N);
    //show_table(cost);
    warshall_floyd(cost);
    //show_table(cost);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j) cost[i][j]=0;
            else if(cost[i][j]<=L) cost[i][j]=1;
            else cost[i][j]=INT_MAX;
        }
    }
    //show_table(cost);
    warshall_floyd(cost);
    //show_table(cost);
    
    for(int q=0;q<Q;q++){
        if(cost[s[q]][t[q]]>INT_MAX*0.9) cout<<-1<<endl;
        else cout<<cost[s[q]][t[q]]-1<<endl;
    }
        
        
    return 0;
}


Compiler output:
a.cc: In function 'vvll cost_table(vll, vll, vll, ll)':
a.cc:14:22: error: 'INT_MAX' was not declared in this scope
   14 |     vvll ret(N,vll(N,INT_MAX));
      |                      ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <algorithm>
  +++ |+#include <climits>
    5 | 
a.cc: In function 'void show_table(vvll)':
a.cc:46:24: error: 'INT_MAX' was not declared in this scope
   46 |             if(d[i][j]>INT_MAX*0.9) printf("M|");
      |                        ^~~~~~~
a.cc:46:24: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc: In function 'int main()':
a.cc:81:29: error: 'INT_MAX' was not declared in this scope
   81 |             else cost[i][j]=INT_MAX;
      |                             ^~~~~~~
a.cc:81:29: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:89:29: error: 'INT_MAX' was not declared in this scope
   89 |         if(cost[s[q]][t[q]]>INT_MAX*0.9) cout<<-1<<endl;
      |                             ^~~~~~~
a.cc:89:29: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'