首页 > 其他 > 详细

ICPC 2019宁夏网络赛

时间:2019-08-31 19:35:34      阅读:156      评论:0      收藏:0      [点我收藏+]

 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;
}

  

ICPC 2019宁夏网络赛

原文:https://www.cnblogs.com/Accpted/p/11440051.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!