#include <bits/stdc++.h>
using namespace std;
int n, m, k, q, adj[70][70], dp[70][70][70];
int main(){
cin >> n >> m;
memset(adj, INT_MAX, sizeof(adj));
for(int i = 0; i < n; i++) adj[i][i] = 0;
while(m--){
int u, v, w; cin >> u >> v >> w;
adj[u - 1][v - 1] = min(adj[u - 1][v - 1], w);
}
cin >> k >> q;
k = (k > n - 1) ? n - 1 : k;
memset(dp, 0x3f, sizeof(dp);
for (int i=0; i<n; ++i)
for (int j=0; j<n; ++j) {
dp[0][i][j]=i==j?0:INF;
dp[1][i][j] = adj[i][j];
}
for(int i = 2; i < k + 1; i++) for(int u = 0; u < n; u++) for(int u2 = 0; u2 < n; u2++) for(int v = 0; v < n; v++) dp[i][u][v] = min(dp[i][u][v], dp[i - 1][u][u2] + adj[u2][v]);
while(q--){
int u, v; cin >> u >> v;
cout << (dp[k][u][v] >= (int)1e9) ? -1 : dp[k][u][v] << '\n';
}
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:16:30: error: expected ')' before ';' token
16 | memset(dp, 0x3f, sizeof(dp);
| ~ ^
| )
Main.cpp:19:23: error: 'INF' was not declared in this scope
19 | dp[0][i][j]=i==j?0:INF;
| ^~~
Main.cpp:25:65: warning: second operand of conditional expression has no effect [-Wunused-value]
25 | cout << (dp[k][u][v] >= (int)1e9) ? -1 : dp[k][u][v] << '\n';
| ^
Main.cpp:25:58: warning: third operand of conditional expression has no effect [-Wunused-value]
25 | cout << (dp[k][u][v] >= (int)1e9) ? -1 : dp[k][u][v] << '\n';
| ~~~~~~~~~~~~^~~~~~~