mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
P2888 [USACO07NOV]Cow Hurdles S
R53028439
This commit is contained in:
parent
6d72585647
commit
e90aeb21d7
30
Luogu/problem/P2888/P2888.cpp
Normal file
30
Luogu/problem/P2888/P2888.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int n, m, t, s, e, h, a, b, f[305][305];
|
||||
|
||||
int main() {
|
||||
cin >> n >> m >> t;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
f[i][j] = i == j ? 0 : INT_MAX;
|
||||
}
|
||||
}
|
||||
for (int i = 1; i <= m; i++) {
|
||||
cin >> s >> e >> h;
|
||||
f[s][e] = h;
|
||||
}
|
||||
for (int k = 1; k <= n; k++) {
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
f[i][j] = min(f[i][j], max(f[i][k], f[k][j]));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < t; i++) {
|
||||
cin >> a >> b;
|
||||
cout << (f[a][b] == INT_MAX ? -1 : f[a][b]) << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user