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天才能运完.货物运输过程中一般要转停好几个码头.物流公司通常会设计一条固定的运输路线 ...
随机推荐
- 文件中的类都不能进行设计,因此未能为该文件显示设计器。设计器检查出文件中有以下类: FormMain --- 未能加载基类“WinForm.Win.FormsBase.FormMainBase”。请确保已引用该程序集并已生成所有项目
出现该问题的原因:FormMain从FormMainBase继承之后,一旦修改FormMainBase就会出现这个问题 解决方案:(1-4是搜索网友的) 1: 关闭VS所有窗口,后重启.即可返回正常. ...
- System.IO.StreamWriter
string path = @"D:\a.txt"; System.IO.StreamWriter swOut = new System.IO.StreamWriter(path, ...
- mysql memory
mysql memory engine 创建: mysql> create table mt engine = memory select * from information_schema.t ...
- [BC]BestCoder Round#86小结
1001 [题意] 给定一个长度为n(n<=100000)的正整数序列,给出m(m<=100000)个子集合和的记录,问哪些一定比正确的记录多了 [题解] 对正整数序列求和,记录比和大的一 ...
- POJ 2823 Sliding Window (线段树/单调队列)
题目不说了,可以用线段树或者单调队列,下面附上代码. 线段树: #include <iostream> #include <stdio.h> #include <algo ...
- [LeetCode]Link List Cycle
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using ex ...
- android 上下文菜单详解
本文使用xml来创建上下文菜单 <?xml version="1.0" encoding="utf-8"?> <menu xmlns:andr ...
- TDD 用语
OOP 封装 继承 多态 SOLID SRP 单一职责 Single Responsibility Principle OCP 开放封闭 Open/Close Principle LS ...
- 李洪强漫谈iOS开发[C语言-037]-if else 语句
李洪强漫谈iOS开发[C语言-037]-if else 语句
- 欧拉工程第68题:Magic 5-gon ring
题目链接 任意一条线上的三个数的和都等于9,顺时针,从最小的外圈开始,得到的序列是:432621213 和 序列 9位的字符串:三角环所能形成的最大字符串为432621513. ...