/*
In the name of Allah
made by: Ahmed_Solyman
*/
#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
//-------------------------------------------------------------//
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sum_to(n) (n*(n+1))/2
#define pb push_back
#define pf push_front
#define fil(arr,x) memset(arr,x,sizeof(arr))
const ll mod=1e9+7;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
//-------------------------------------------------------------//
ll lcm(ll a,ll b)
{
return (max(a,b)/__gcd(a,b))*min(a,b);
}
void person_bool(bool x)
{
cout<<(x?"YES":"NO")<<endl;
}
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
#ifndef ONLINE_JUDGE
//freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
#endif
fast
int n,m;cin>>n>>m;
ll dp[n+5][n+5][n+5];
for(int i=0;i<=n;i++){
for(int j=0;j<=n;j++){
for(int k=0;k<=n;k++){
if(i==j){
dp[i][j][k]=0;
continue;
}
dp[i][j][k]=2e18;
}
}
}
for(int i=0;i<m;i++){
int u,v,w;cin>>u>>v>>w;
dp[u][v][1]=w;
}
for(int k=2;k<n;k++){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(i==j){
continue;
}
for(int u=1;u<=n;u++){
for(int p=1;p<k;p++){
dp[i][j][k]=min(dp[i][j][k],dp[i][u][p],dp[u][j][k-p]);
}
}
}
}
}
int k,q;cin>>k>>q;
k=min(k,n-1);
while(q--){
int u,v;cin>>u>>v;
cout<<dp[u][v][k]<<endl;
}
return 0;
}
Compilation message
In file included from /usr/include/c++/10/bits/char_traits.h:39,
from /usr/include/c++/10/ios:40,
from /usr/include/c++/10/istream:38,
from /usr/include/c++/10/sstream:38,
from /usr/include/c++/10/complex:45,
from /usr/include/c++/10/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
from Main.cpp:5:
/usr/include/c++/10/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]':
Main.cpp:72:63: required from here
/usr/include/c++/10/bits/stl_algobase.h:281:17: error: '__comp' cannot be used as a function
281 | if (__comp(__b, __a))
| ~~~~~~^~~~~~~~~~