# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
879720 |
2023-11-28T02:13:51 Z |
Alora |
Autobus (COCI22_autobus) |
C++17 |
|
4 ms |
3676 KB |
#include <bits/stdc++.h>
#define Alora "cownav"
#define fi(i,a,b) for(int i = a; i <= b; i++)
#define fid(i,a,b) for(int i = a; i >= b; i--)
#define ll long long
#define f first
#define se second
#define pii pair<int, int>
#define getbit(i, j) ((i >> j) & 1)
#define all(v) v.begin(), v.end()
#define pb push_back
#define maxn 75
const int M = 1e9 + 7;
using namespace std;
int n, m, k, q;
ll dp[maxn][maxn][maxn];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
if(fopen(Alora".inp", "r")){
freopen(Alora".inp", "r", stdin);
freopen(Alora".out", "w", stdout);}
cin >> n >> m;
memset(dp, 60, sizeof(dp));
fi(i, 1, n) dp[0][i][i] = 0;
fi(i, 1, m){
int a, b, c;
cin >> a >> b >> c;
dp[1][a][b] = min(dp[1][a][b], 1ll*c);
}
cin >> k >> q;
k = min(k, n - 1);
fi(t, 1, n)
fi(d, 0, k - 1)
fi(u, 1, n)
fi(v, 1, n)
dp[d + 1][u][v] = min(dp[d + 1][u][v], dp[d][u][t] + dp[1][t][v]);
while(q--){
int u, v; cin >> u >> v;
ll ans = 1e18;
fi(d, 0, k) ans = min(ans, dp[d][u][v]);
if(ans != 1e18) cout << ans << '\n';
else cout << -1 << '\n';
}
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
21 | freopen(Alora".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | freopen(Alora".out", "w", stdout);}
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3676 KB |
Output is correct |
2 |
Incorrect |
1 ms |
3652 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3676 KB |
Output is correct |
2 |
Correct |
2 ms |
3676 KB |
Output is correct |
3 |
Incorrect |
4 ms |
3676 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3676 KB |
Output is correct |
2 |
Incorrect |
1 ms |
3652 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3676 KB |
Output is correct |
2 |
Incorrect |
1 ms |
3652 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |