# BZOJ2662 [BeiJing wc2012]冻结

 1 /**************************************************************
2     Problem: 2662
3     User: rausen
4     Language: C++
5     Result: Accepted
6     Time:520 ms
7     Memory:1472 kb
8 ****************************************************************/
9
10 #include <cstdio>
11 #include <cstring>
12
13 using namespace std;
14 const int N = 55;
15
16 int n, m, K;
17 int f[N][N][N];
18 int ans;
19
20 inline int min(int x, int y) {
21     return x < y ? x : y;
22 }
23
24 int main() {
25     int x, y, z;
26     scanf("%d%d%d", &n, &m, &K);
27     memset(f, 0x3f, sizeof(f));
28     for (int i = 1; i <= m; ++i) {
29         scanf("%d%d%d", &x, &y, &z);
30         f[x][y][0] = f[y][x][0] = z;
31         f[x][y][1] = f[y][x][1] = z / 2;
32     }
33     for (int k = 1; k <= n; ++k)
34         for (int i = 1; i <= n; ++i)
35             for (int j = 1; j <= n; ++j)
36                 for (int p = 0; p <= K; ++p)
37                     for (int q = 0; q <= p; ++q) {
38                         f[i][j][p] = min(f[i][j][p], f[i][k][q] + f[k][j][p - q]);
39                     }
40     ans = 1e9;
41     for (int p = 0; p <= K; ++p)
42         ans = min(ans, f[1][n][p]);
43     printf("%d\n", ans);
44     return 0;
45 }
46 
View Code

posted on 2019-03-20 11:59  Xs酱~  阅读(...)  评论(...编辑  收藏