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天才能运完.货物运输过程中一般要转停好几个码头.物流公司通常会设计一条固定的运输路线 ...
随机推荐
- anroid ndk编译ffmpeg 引用librtmp libx264
Ffmpeg 无处不在,自然android系统少不了它,折腾了不少时间完成 ndk编译ffmpeg,生成so库中引用了外部库librtmp,libx264.条条大路通罗马, 也许还有别的更好的方法去完 ...
- js获取对象、数组的实际长度,元素实际个数
/*获取对象.数组的长度.元素个数 *@param obj 要计算长度的元素,可以为object.array.string */ function count(obj){ var objType = ...
- JAVA里的String、Timestamp、Date相互转换(转)
转自:http://blog.sina.com.cn/s/blog_6675493d0100lbfl.html Timestamp转化为String: SimpleDateFormat df = ne ...
- protocol buffer 整数序列化
http://blog.csdn.net/csfreebird/article/details/7624807 varints用于正整数 (无符号整数) varints 是 一个很不错的技术.将一个整 ...
- bzoj 1295: [SCOI2009]最长距离 暴力+bfs最短路
题目链接: http://www.lydsy.com/JudgeOnline/problem.php?id=1295 题解: 对每个点暴力跑一遍bfs,看能够到达的最远位置,这里如果有障碍物则距离为1 ...
- 【BZOJ】【1022】【SHOI2008】小约翰的游戏John
博弈论 一看题,哇这不是Nim游戏么= =直接异或起来……啊咧怎么不对? 这道题是[Anti-Nim],普通的Nim是取走最后一个就赢,这题是取走最后一个输…… 做法参见 2009年贾志豪论文< ...
- table 与 div 固定宽高问题
div {width:100px;height:200px;word-wrap: break-word;overflow:hidden;} 这个可以固定div的宽高,溢出内容会被剪除. table{t ...
- LightOj 1096 - nth Term (矩阵快速幂,简单)
题目 这道题是很简单的矩阵快速幂,可惜,在队内比赛时我不知什么时候抽风把模版中二分时判断的 ==1改成了==0 ,明明觉得自己想得没错,却一直过不了案例,唉,苦逼的比赛状态真让人抓狂!!! #incl ...
- poj 2485 Highways(最小生成树,基础,最大边权)
题目 //听说听木看懂之后,数据很水,我看看能不能水过 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stri ...
- ubuntu下hadoop2.6在eclipse上的配置
1.复制hadoop-eclipse-plugin-2.6.0.jar插件到eclipse的plugins目录下(hadoop2.6的插件,在hadoop自带上没有,要上网下载,多试几个 如果是从ub ...