水题,裸的最短路。

const maxn=;
type
link=^node;
node=record
t,d:longint;
f:link;
end;
var n,m,s,i,j,u,v,w,max:longint;
adj:array[..] of link;
f:array[..] of longint;
d,val:array[..] of longint;
went:array[..] of boolean;
procedure insert(f,t,d:longint);
var p:link;
begin
new(p);
p^.f:=adj[f];
p^.t:=t;
p^.d:=d;
adj[f]:=p;
end;
procedure spfa(s:longint);
var l,r,now,i:longint;
p:link;
begin
for i:= to n do
d[i]:=maxn;
fillchar(went,sizeof(went),true);
l:=; r:=; f[]:=s; d[s]:=; went[s]:=false;
while l<=r do
begin
now:=f[l];
p:=adj[now];
while p<>nil do
begin
if d[p^.t]>d[now]+p^.d then
begin
d[p^.t]:=d[now]+p^.d;
if went[p^.t] then
begin
went[p^.t]:=false;
inc(r);
f[r]:=p^.t;
end;
end;
p:=p^.f;
end;
went[now]:=true;
inc(l);
end;
end;
begin
readln(n,m,s);
for i:= to m do
begin
readln(u,v,w);
insert(u,v,w);
//insert(v,u,w);
end;
for i:= to n do
if i<>s then
begin
spfa(i);
val[i]:=d[s];
end;
spfa(s);
for i:= to n do
if i<>s then
begin
inc(val[i],d[i]);
if val[i]>max then max:=val[i];
end;
writeln(max);
end.

(转载请注明出处:http://www.cnblogs.com/Kalenda/)

P3408: [Usaco2009 Oct]Heat Wave 热浪的更多相关文章

  1. BZOJ 3408: [Usaco2009 Oct]Heat Wave 热浪( 最短路 )

    普通的最短路...dijkstra水过.. ------------------------------------------------------------------------------ ...

  2. 3408: [Usaco2009 Oct]Heat Wave 热浪

    3408: [Usaco2009 Oct]Heat Wave 热浪 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 67  Solved: 55[Subm ...

  3. [Usaco2009 Oct]Heat Wave 热浪(裸最短路径)

    链接:https://ac.nowcoder.com/acm/contest/1082/F来源:牛客网 题目描述 The good folks in Texas are having a heatwa ...

  4. BZOJ3408: [Usaco2009 Oct]Heat Wave 热浪

    最短路模板.选迪杰. #include<stdio.h> #include<string.h> #include<stdlib.h> #include<alg ...

  5. 洛谷—— P1339 [USACO09OCT]热浪Heat Wave

    P1339 [USACO09OCT]热浪Heat Wave 题目描述 The good folks in Texas are having a heatwave this summer. Their ...

  6. Luogu P1339 热浪Heat Wave

    Luogu P1339 热浪Heat Wave 裸·单源最短路. 但是! 有以下坑点: 算过复杂度发现Floyd跑不过去就不要用了. 如果建边是双向边,边的数组大小要开两倍! 考场上如果再把初始化的$ ...

  7. BZOJ 3407: [Usaco2009 Oct]Bessie's Weight Problem 贝茜的体重问题( dp )

    01背包... ----------------------------------------------------------------------- #include<cstdio&g ...

  8. 3406: [Usaco2009 Oct]Invasion of the Milkweed 乳草的入侵

    3406: [Usaco2009 Oct]Invasion of the Milkweed 乳草的入侵 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 8 ...

  9. 3409: [Usaco2009 Oct]Barn Echoes 牛棚回声

    3409: [Usaco2009 Oct]Barn Echoes 牛棚回声 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 57  Solved: 47[ ...

随机推荐

  1. 深入了解Qt(二)之元对象系统(Meta-Object System)

    深入了解Qt主要内容来源于Inside Qt系列,本文做了部分删改,以便于理解.在此向原作者表示感谢! 在Qt Meta Object System-元对象系统这篇文章中,从底层实现的源码剖析了元对象 ...

  2. 跨域请求之JSONP 三

    script请求返回JSON实际上是脚本注入.它虽然解决了跨域问题,但它不是万能的. 不能接受HTTP状态码 不能使用POST提交(默认GET) 不能发送和接受HTTP头 不能设置同步调用(默认异步) ...

  3. 使用SSL确保通信中的数据安全

    #region Server /// <summary> /// 用于保存非对称加密(数字证书)的公钥 /// </summary> private string public ...

  4. Groovy轻松入门——搭建Groovy开发环境

    摘自: http://www.blogjava.net/BlueSUN/archive/2007/03/17/104391.html Groovy轻松入门--搭建Groovy开发环境 多日来,我发表了 ...

  5. SQL Server 之登录

    1:SQL Server 是Microsoft 公司推出的关系型数据库管理系统. 安装好后,开始登录. 2:几种登录方式: (1):服务器名称: ①: . :代表本地服务器 ②: local :代表本 ...

  6. grep,awk和sed的常用命令和语法

    Grep的常用命令语法 1. 双引号引用和单引号引用在g r e p命令中输入字符串参数时,最好将其用双引号括起来.例如:“m y s t r i n g”.这样做有两个原因,一是以防被误解为 s h ...

  7. 【转】Linux Writeback机制分析

    1. bdi是什么? bdi,即是backing device info的缩写,顾名思义它描述备用存储设备相关描述信息,这在内核代码里用一个结构体backing_dev_info来表示. bdi,备用 ...

  8. Web Service 中返回DataSet结果的几种方法

    Web Service 中返回DataSet结果的几种方法: 1)直接返回DataSet对象    特点:通常组件化的处理机制,不加任何修饰及处理:    优点:代码精减.易于处理,小数据量处理较快: ...

  9. asp 301跳转代码

    <%    Response.Status="301 Moved Permanently"     Response.AddHeader "Location&quo ...

  10. 解决dropdownlist postback 在 iphone UIwebview 失效的问题

    原因: IPhone UIWebView 的 用户代理 User Agent 在ASP.NET 4.0环境下是不识别的:所以ASP.NET提供了一个默认的,低级的不包括javascript的页面版本 ...