水题,裸的最短路。

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. use python get information from one page

    #!/usr/bin/python read = file('thread-1554-1-1.html','r') wr = file('list','w') while 1: line=read.r ...

  2. Android:控件布局(表格布局)TableLayout

    TableLayout继承LinearLayout 实例:用表格布局实现计算机布局>>>>>>>>>>>> 有多少个TableR ...

  3. 017Makefile工程管理

    1.为什么需要Makefile? 利用Makefile和make的合作,可以把很多很多的工作合并成一个非常简单的命令:make: make能够使整个程序的编译.链接只需要一个命令(make)就可以完成 ...

  4. Linux日志

    一.Linux 常見的日志文件 /var/log/cron:你的 crontab 排程有没有实际被进行? 进行过程有没有发生错误?你的 /etc/crontab 是否撰写正确?在这个登录档内查询看看. ...

  5. HTML框架标签

    与HTML框架有关的标签主要有三种: <frameset>框架结构标签 <frame>框架标签 <iframe>内联框架标签 一. 先来说第一种框架结构标签 < ...

  6. Nginx 开启 path_info功能

    server { listen ; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; roo ...

  7. CentOS6.5配置vim使支持Python

    CentOS6.5下开启vim对python的支持,配置方法如下: 1.检查系统已经安装了RPM包vim-enhanced; 2.复制默认的.vimrc初始化文件: # cp /usr/share/v ...

  8. 基于s5pv210嵌入式linux系统sqlite3数据库移植

    基于s5pv210嵌入式linux系统sqlite3数据库移植 1.下载源码 http://www.sqlite.org/download.html 最新源码为3080100 2.解压 tar xvf ...

  9. asp.net跨页面传值

    a.aspx.cs //获取a中的id HttpCookie objCookie = new HttpCookie("myCookie", id); Response.Cookie ...

  10. Knockout.Js官网学习(visible绑定)

    前言 让visible绑定到DOM元素上,使得该元素的hidden或visible取决于绑定的值. 简单的绑定 首先还是先定义一个ViewModel var AppViewModel = { shou ...