开始没理解题意。原来destinations是指路的序号。而不是点。DP。
1 #include2 #include 3 4 int dp[2005]; 5 6 typedef struct { 7 int s, e, w; 8 } road_st; 9 10 road_st roads[2005];11 12 int main() {13 int case_n;14 int n, m, des;15 int i, j, min;16 17 scanf("%d", &case_n);18 19 while (case_n--) {20 scanf("%d%d", &n, &m);21 for (i=1; i<=n; ++i)22 scanf("%d%d%d", &roads[i].s, &roads[i].e, &roads[i].w);23 memset(dp, 0, sizeof(dp));24 dp[1] = roads[1].w;25 for (i=2; i<=n; ++i) {26 min = 0x7fffffff;27 for (j=1; j