热浪[TYVJ1031]

描述

德克萨斯纯朴的民眾们这个夏天正在遭受巨大的热浪!!!他们的德克萨斯长角牛吃起来不错,可是他们并不是很擅长生產富含奶油的乳製品。Farmer John此时以先天下之忧而忧,后天下之乐而乐的精神,身先士卒地承担起向德克萨斯运送大量的营养冰凉的牛奶的重任,以减轻德克萨斯人忍受酷暑的痛苦。

FJ已经研究过可以把牛奶从威斯康星运送到德克萨斯州的路线。这些路线包括起始点和终点先一共经过T (1 <= T <= 2,500)个城镇,方便地标号為1到T。除了起点和终点外地每个城镇由两条双向道路连向至少两个其它地城镇。每条道路有一个通过费用(包括油费,过路费等等)。考虑这个有7个城镇的地图。城镇5是奶源,城镇4是终点(括号内的数字是道路的通过费用)。

[1]----1---[3]-
                             /               \
                      [3]---6---[4]---3--[3]--4
                     /               /       /|
                    5         --[3]--  --[2]- |
                     \       /        /       |
                      [5]---7---[2]--2---[3]---
                            |       /
                           [1]------

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAc4AAAGfCAIAAABZVqW1AAAgAElEQVR4Ae2dO3IcudZuizd6KGIbHRoBNQLxd9pqVx5lis6ZwfF+hzJFT25b7RxyBKR7nY5jNBlxh8K7q0CCWVn5QOK5Aaw0yHwA+7E28BUq63X28H//344NAhCAAARSEvg/KY1jGwIQgAAE9gTOXl5eIAEBCEAAAkkJsKpNihfjEIAABPYEkFrGAQQgAIHkBJDa5IhxAAEIQACpZQxAAAIQSE4AqU2OGAcQgAAEkFrGAAQgAIHkBJDa5IhxAAEIQACpZQxAAAIQSE4AqU2OGAcQgAAEkFrGAAQgAIHkBJDa5IhxAAEIQACpZQxAAAIQSE4AqU2OGAcQgAAEkFrGAAQgAIHkBH5J7gEHPRE4OztzSZev7nShRJuWCCC1LVWzQC4jbXXUUL9eBdLDJQQiEeCrwSOB7M+MkUtHbV3GY5U3irVlX1yFQBECSG0R7BU7TSqLSY1XDJ3Q6yeA1NZfw1wZRFzGroac09dqMDSAQDgBpDacYRcWRPvyP7tH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uoI1lAAAKqCSC1qstDcBCAQBsEkNo26kgWEICAagJIreryEBwEINAGAaS2jTqSBQQgoJoAUqu6PAQHAQi0QQCpbaOOZAEBCKgmgNSqLg/BQQACbRBAatuoI1lAAAKqCfx/DWe3i8dKGxcAAAAASUVORK5CYII=" alt="" />

经过路线5-6-3-4总共需要花费3 (5->6) + 4 (6->3) + 3 (3->4) = 10的费用。

给定一个地图,包含C (1 <= C <= 6,200)条直接连接2个城镇的道路。每条道路由道路的起点Rs,终点Re (1 <= Rs <= T; 1 <= Re <= T),和花费(1 <= Ci <= 1,000)组成。求从起始的城镇Ts (1 <= Ts <= T)到终点的城镇Te(1 <= Te <= T)最小的总费用。

输入格式

* 第一行: 4个由空格隔开的整数: T, C, Ts, Te

* 第2到第C+1行: 第i+1行描述第i条道路。有3个由空格隔开的整数: Rs, Re和Ci

输出格式

* 第一行: 一个单独的整数表示Ts到Te的最短路的长度。(不是费用麼?怎麼突然变直白了
——译者注)数据保证至少存在一条道路。

测试样例1

输入

7 11 5 4 
2 4 2 
1 4 3 
7 2 2 
3 4 3 
5 7 5 
7 3 3 
6 1 1 
6 3 4 
2 4 3 
5 6 3 
7 2 1

输出

7

 
#include <stdio.h>
#include <string.h>
#include <queue>
using namespace std;
int d[], dd[][];
bool v[];
queue<int> q;
int main() {
int t, c, s, e;
scanf("%d%d%d%d", &t, &c, &s, &e);
memset(dd, , sizeof(dd));
for (int i = ; i < c; i++) {
int p, q, m;
scanf("%d%d%d", &p, &q, &m);
dd[p][q] = dd[q][p] = m;
}
memset(d, 0x7F, sizeof(d));
d[s] = ;
while (!q.empty()) {
q.pop();
}
q.push(s);
memset(v, false, sizeof(v));
v[s] = true;
while (!q.empty()) {
int x = q.front();
q.pop();
v[x] = false;
for (int i = ; i <= t; i++) {
if (dd[x][i] == ) {
continue;
}
if (d[x] + dd[x][i] < d[i]) {
d[i] = d[x] + dd[x][i];
if (!v[i]) {
v[i] = true;
q.push(i);
}
}
}
}
printf("%d\n", d[e]);
return ;
}
上一篇:委托(delegate)的三种调用方式:同步调用,异步调用,异步回调(转载)


下一篇:C#委托的异步调用1