ICPC 2019宁夏网络赛
作者:互联网
ICPC 2019宁夏网络赛
Maximum Element In A Stack
Rolling The Polygon
Caesar Cipher
Take Your Seat
Moving On
#include<bits/stdc++.h> using namespace std; typedef long long ll; int n,m,k,q; int dp[210][210][210]; int d[210],id[210]; bool cmp(int x,int y) { return d[x] < d[y]; } int main() { int _,ca=0; scanf("%d", &_); while (_--) { memset(dp, 0x3f, sizeof(dp)); scanf("%d%d", &n, &q); for (int i = 1; i <= n; i++) { scanf("%d", &d[i]); id[i] = i; } sort(id + 1, id + 1 + n, cmp); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { scanf("%d", &dp[0][i][j]); } } for (int k = 1; k <= n; k++) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { dp[k][i][j] = min(dp[k - 1][i][j], dp[k - 1][i][id[k]] + dp[k - 1][id[k]][j]); } } } printf("Case #%d:\n",++ca); for (int i = 1; i <= q; i++) { int u, v, w; scanf("%d%d%d", &u, &v, &w); int k = 0; for (int i = 1; i <= n; i++) { if (d[id[i]] <= w) { k = i; } } printf("%d\n", dp[k][u][v]); } } return 0; }
标签:210,int,scanf,宁夏,ICPC,2019,long,dp 来源: https://www.cnblogs.com/Accpted/p/11440051.html