ZJOI2006物流运输
唉,没想出来……
注意到预处理的作用。还有CLJ大牛说的话:这么小的数据,想干什么都可以。
SPFA预处理+DP 够经典
var
f:array[..,..]of longint;
a:array[..,..]of boolean;
head,next,go,w,q:array[..]of longint;
dis:array[..]of longint;
v,can:array[..]of boolean;
n,m,k,e,tot,l,r,h,t:longint; function min(x,y:longint):longint;
begin
if x<y then exit(x);
exit(y);
end; procedure spfa;
var
i,j,x:longint;
begin
h:=;
t:=;
q[]:=;
for i:= to m do
dis[i]:=;
dis[]:=;
for i:= to m do
v[m]:=false;
v[]:=true;
for i:= to m do
begin
can[i]:=true;
for j:=l to r do
if a[i,j] then can[i]:=false;
end;
while h<=t do
begin
inc(h);
x:=q[h];
v[x]:=false;
i:=head[x];
while i<> do
begin
j:=go[i];
if can[j] then
if dis[j]>dis[x]+w[i] then
begin
dis[j]:=dis[x]+w[i];
if v[x]=false then
begin
inc(t);
v[j]:=true;
q[t]:=j;
end;
end;
i:=next[i];
end;
end;
f[l,r]:=dis[m]*(r-l+);
end; procedure insert(x,y,z:longint);
begin
inc(tot);
go[tot]:=y;
next[tot]:=head[x];
head[x]:=tot;
w[tot]:=z;
end; procedure init;
var
i,j,x,y,z:longint;
begin
read(n,m,k,e);
for i:= to e do
begin
read(x,y,z);
insert(x,y,z);
insert(y,x,z);
end;
read(e);
fillchar(a,sizeof(a),false);
for i:= to e do
begin
read(x,y,z);
for j:=y to z do
a[x,j]:=true;
end;
for l:= to n do
for r:=l to n do
spfa;
end;
procedure dp;
var
i,j,l:longint;
begin
for i:= to n- do
for j:= to n-i do
for l:=j to i+j- do
f[j,i+j]:=min(f[j,i+j],f[j,l]+k+f[l+,i+j]);
write(f[,n]);
end; begin
init;
dp;
end.
ZJOI2006物流运输的更多相关文章
- [ZJOI2006]物流运输
1003: [ZJOI2006]物流运输 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 5999 Solved: 2473[Submit][Stat ...
- bzoj1003 [ZJOI2006]物流运输
1003: [ZJOI2006]物流运输 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 6300 Solved: 2597[Submit][Stat ...
- 【bzoj1003】[ZJOI2006]物流运输
1003: [ZJOI2006]物流运输 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 6331 Solved: 2610[Submit][Stat ...
- bzoj1003: [ZJOI2006]物流运输
dp+最短路.暴力枚举就可以了.O(n3logn).样例中m=n然后测样例过了.然后 54行习惯性的dis[n]然后就WA了!!!. #include<cstdio> #include&l ...
- BZOJP1003 [ZJOI2006]物流运输trans
BZOJP1003 [ZJOI2006]物流运输trans 1003: [ZJOI2006]物流运输trans Time Limit: 10 Sec Memory Limit: 162 MB Sub ...
- BZOJ 1003 [ZJOI2006]物流运输trans
1003: [ZJOI2006]物流运输trans Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 4242 Solved: 1765[Submit] ...
- bzoj1003[ZJOI2006]物流运输trans
1003: [ZJOI2006]物流运输trans Description 物流公司要把一批货物从码头A运到码头B.由于货物量比较大,需要n天才能运完.货物运输过程中一般要转停好几个码头.物流公司通常 ...
- BZOJ 1003: [ZJOI2006]物流运输trans(最短路+dp)
1A,爽! cost[i][j]表示从第i天到第j天不改路线所需的最小花费,这个可以用最短路预处理出.然后dp(i)=cost[j][i]+dp(j-1)+c. c为该路线的花费. --------- ...
- BZOJ_1003_[ZJOI2006]物流运输_最短路+dp
BZOJ_1003_[ZJOI2006]物流运输_最短路+dp 题意:http://www.lydsy.com/JudgeOnline/problem.php?id=1003 分析: 这种一段一段的显 ...
- 洛谷P1772 [ZJOI2006]物流运输
P1772 [ZJOI2006]物流运输 题目描述 物流公司要把一批货物从码头A运到码头B.由于货物量比较大,需要n天才能运完.货物运输过程中一般要转停好几个码头.物流公司通常会设计一条固定的运输路线 ...
随机推荐
- Android journey3 @点击事件的4种写法
对于android布局中的控件,如Button等会有相应的点击事件去响应它所需要的功能,今天我们就以电话拨号器的代码说明下几种点击事件: package com.itheima.phone; impo ...
- SQL Server 创建表 添加主键 添加列常用SQL语句【转】
--删除主键alter table 表名 drop constraint 主键名--添加主键alter table 表名 add constraint 主键名 primary key(字段名1,字段名 ...
- java 获取获取字符串编码格式
public static String getEncoding(String str) { String encode = "GB2312"; try { if (str.equ ...
- 【BZOJ】【2223】【COCI 2009】PATULJCI
可持久化线段树 同BZOJ 3524,但是不要像我一样直接贴代码……TAT白白WA了一次,so sad /*********************************************** ...
- input点击删除默认value,以及只能输入数字,删除,tab
/*inputhastip类绑定事件*/ $('.inputhastip').css("color", "#999"); $('.inputhastip').b ...
- linux源码阅读笔记 move_to_user_mode()解析
在linux 0.11版本源代码中,在文件linux/include/asm/system.h中有一个宏定义 move_to_user_mode() 1 #define move_to_user_m ...
- hdu 1875 畅通工程再续(最小生成树,基础)
题目 让人郁闷的题目,wa到死了,必须要把判断10.0和1000.0的条件放到prim函数外面去.如代码所放.... 正确的(放在prim外): //2个小岛之间的距离不能小于10米,也不能大于100 ...
- Javascript 选项卡
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- java基础知识回顾之---java StringBuffer类
/* * StringBuffer:就是字符串缓冲区,线程安全. * 用于存储数据的容器. * 特点: * 1,长度的可变的. ...
- 乳草的入侵//BFS
P1030 乳草的入侵 时间: 1000ms / 空间: 131072KiB / Java类名: Main 背景 USACO OCT09 6TH 描述 Farmer John一直努力让他的草地充满鲜美 ...