标签:const eof div blocks nbsp set wro using pre
// Hey buddy you get the wrong door, the leather club is two blocks down. #include <bits/stdc++.h> using namespace std; const int N = 200, INF = 0x3f3f3f3f; int t[N + 5], dis[N + 5][N + 5]; int n, m; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) scanf("%d", &t[i]); memset(dis, 63, sizeof(dis)); for (int i = 1, u, v, w; i <= m; i++) scanf("%d%d%d", &u, &v, &w), u++, v++, dis[u][v] = w, dis[v][u] = w; for (int i = 1; i <= n; i++) dis[i][i] = 0; int q, k = 1; for (scanf("%d", &q); q--;) { int u, v, o; scanf("%d%d%d", &u, &v, &o), u++, v++; for (; t[k] <= o && k <= n; k++) for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]); printf("%d\n", dis[u][v] == INF || t[u] > o || t[v] > o ? -1 : dis[u][v]); } return 0; }
标签:const eof div blocks nbsp set wro using pre
原文地址:https://www.cnblogs.com/oply/p/12878125.html