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天才能运完.货物运输过程中一般要转停好几个码头.物流公司通常会设计一条固定的运输路线 ...
随机推荐
- Jquery 固定悬浮层以及固定表头
/* =========================================================== * jquery.autofix_anything.js v1 * === ...
- UEFI+GPT 修复 win10启动
要修复引导文件大致有以下几个步骤(按照我自己修复的步骤来的,其他情况可结合上面参考资料探索,大体思路应该没有变化): 挂载ESP分区 由于我的windows8.1已经无法进入了,Ubuntu不知道能不 ...
- 几款实用的 JavaScript 图形图表库
一款好的图表插件不是那么容易找到的.最近项目里需要实现统计图表功能,所以在网上搜罗了一圈,找到一些不错的图表插件,分享大家.众多周知,图形和图表要比文本更具表现力和说服力.这里给大家精心推荐几款实用的 ...
- java 伪静态的方法
1.jar包支持urlrewritefilter-4.0.3.jar http://files.cnblogs.com/simpledev/urlrewritefilter-4.0.3.rar 2. ...
- C#三种定时器的实现
http://www.coridc.com/archives/2253.html c#中提供了三种类型的计时器: 1.基于 Windows 的标准计时器(System.Windows.Forms.Ti ...
- POJ 1663
#include<iostream>//cheng da cai zi using namespace std; int main() { int time; cin>>tim ...
- java基础知识回顾之java Thread类学习(七)--java多线程安全问题(死锁)
死锁:是两个或者两个以上的线程被无限的阻塞,线程之间互相等待所需资源. 线程死锁产生的条件: 当两个线程相互调用Join()方法. 当两个线程使用嵌套的同步代码块的时候,一个线程占用了另一个线程的锁, ...
- 获取SqlDataReader的列名
SqlConnection thisConnection = new SqlConnection(ConfigurationManager.AppSettings["ConnectionSt ...
- CKeditor 配置使用
CKeditor 配置使用 一.使用方法:1.在页面<head>中引入ckeditor核心文件ckeditor.js<script type="text/javascrip ...
- 231. Power of Two
题目: Given an integer, write a function to determine if it is a power of two. 链接: http://leetcode.com ...