poj3216
这是一道描述非常不清楚的题目
首先解释一下,题目中的ti是任务开始时间不是结束时间,
然后维修人员可以理解为可以再任意时间从公司出发;
好,首先不难想到用floyd预处理一下;
然后我们把每个任务看成一个点,显然有些维修员完成一个任务后还可以接着完成别的任务;
这样我们就可以构造出一张有向无环图;
考虑到每个任务这需要我们做一次且仅一次,并且现在我们要求最少的人去覆盖所有的点;
不难想到最小路径覆盖,构造二分图求解即可
const inf=;
type node=record
next,point:longint;
end; var edge:array[..] of node;
p,cx,cy,d,s,w:array[..] of longint;
v:array[..] of boolean;
a:array[..,..] of longint;
len,ans,i,j,n,m,k:longint; function min(a,b:longint):longint;
begin
if a>b then exit(b) else exit(a);
end; procedure add(x,y:longint);
begin
inc(len);
edge[len].point:=y;
edge[len].next:=p[x];
p[x]:=len;
end; function find(x:longint):longint;
var i,y:longint;
begin
i:=p[x];
while i<>- do
begin
y:=edge[i].point;
if not v[y] then
begin
v[y]:=true;
if (cy[y]=-) or (find(cy[y])=) then
begin
cx[x]:=y;
cy[y]:=x;
exit();
end;
end;
i:=edge[i].next;
end;
exit();
end; begin
readln(n,m);
while (n<>) do
begin
len:=;
fillchar(p,sizeof(p),);
for i:= to n do
for j:= to n do
begin
read(a[i,j]);
if a[i,j]=- then a[i,j]:=inf;
end;
for k:= to n do
for i:= to n do
if (i<>k) then
for j:= to n do
if (i<>j) and (j<>k) then
a[i,j]:=min(a[i,j],a[i,k]+a[k,j]);
for i:= to m do
readln(w[i],s[i],d[i]);
for i:= to m do
for j:= to m do
begin
if i=j then continue;
if a[w[i],w[j]]+s[i]+d[i]<=s[j] then add(i,j);
end;
ans:=;
fillchar(cx,sizeof(cx),);
fillchar(cy,sizeof(cy),);
for i:= to m do
if cx[i]=- then
begin
fillchar(v,sizeof(v),false);
ans:=ans+find(i);
end;
writeln(m-ans);
readln(n,m);
end;
end.
poj3216的更多相关文章
- POJ3216 最小路径覆盖
首先说一下题意,Q个区域,M个任务,每个区域任务可能有多个,然后给你个到各地所需时间的矩阵,每个任务都有开始和持续时间,问最少需要多少工人? 每个工人只能同时执行一个任务. 通过题意,我的瞬间反应就是 ...
- poj3216 Prime Path(BFS)
题目传送门 Prime Path The ministers of the cabinet were quite upset by the message from the Chief of Sec ...
- poj分类 很好很有层次感。
初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. ( ...
- 【转】POJ题目分类推荐 (很好很有层次感)
OJ上的一些水题(可用来练手和增加自信) (poj3299,poj2159,poj2739,poj1083,poj2262,poj1503,poj3006,poj2255,poj3094)初期: 一. ...
- 【转】ACM训练计划
[转] POJ推荐50题以及ACM训练方案 -- : 转载自 wade_wang 最终编辑 000lzl POJ 推荐50题 第一类 动态规划(至少6题, 和 必做) 和 (可贪心) (稍难) 第二类 ...
- POJ 题目分类(转载)
Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...
- (转)POJ题目分类
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
- acm常见算法及例题
转自:http://blog.csdn.net/hengjie2009/article/details/7540135 acm常见算法及例题 初期:一.基本算法: (1)枚举. (poj17 ...
- poj分类
初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. ( ...
随机推荐
- Java学习笔记:语言基础
Java学习笔记:语言基础 2014-1-31 最近开始学习Java,目的倒不在于想深入的掌握Java开发,而是想了解Java的基本语法,可以阅读Java源代码,从而拓展一些知识面.同时为学习An ...
- WPF学习笔记4——Layout之2
下面简单介绍常见的面板. 一.Grid 1.Grid关于调整行列距离有三种方法:绝对大小,自动大小,比例大小.如下: <ColumnDefinition Width="100" ...
- 《WPF程序设计指南》读书笔记——第2章 基本画刷
1.Color结构 using System; using System.Windows; using System.Windows.Input; using System.Windows.Media ...
- 实现Linux select IO复用C/S服务器代码
已在ubuntu 下验证可用 服务器端 #include<stdio.h>#include<unistd.h>#include<stdlib.h>#include& ...
- .htaccess 设置
RewriteEngine on RewriteCond %{HTTP_HOST} ^blog.chosenet.com$RewriteCond %{REQUEST_URI} !^/blog/Rew ...
- 外部表查询时出现ORA-29913和ORA-29400错误
create table t_ext_tab(id char(1),name char(6)) organization external( type oracle_loader default di ...
- 演示demo开发问题及解决方案集锦
模型处理问题: 1. 3Dmax模型导入Unity单位设置: 自定义->单位设置->系统单位设置与显示单位比例都调成厘米 2. 3Dmax中材质贴图: 点击材质编辑器[在模式下可以选择精简 ...
- POJ - 1741 Tree
DescriptionGive a tree with n vertices,each edge has a length(positive integer less than 1001).Defin ...
- myeclipse报jar包missing
一.问题描述 从版本库中check out项目后,发现项目有“感叹号”,且pom.xml文件有红色的“差号”.如下图: 在error window里可以看到missing jar包的提示,如下: 打开 ...
- Mesh Baker的基本操作与功能演示
原地址:http://www.narkii.com/club/thread-301789-1.html 如何降低游戏在系统中的消耗并带给用户最佳的体验是开发者一直追求的目标,在Unity里面对于模型与 ...