这是一道描述非常不清楚的题目

首先解释一下,题目中的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的更多相关文章

  1. POJ3216 最小路径覆盖

    首先说一下题意,Q个区域,M个任务,每个区域任务可能有多个,然后给你个到各地所需时间的矩阵,每个任务都有开始和持续时间,问最少需要多少工人? 每个工人只能同时执行一个任务. 通过题意,我的瞬间反应就是 ...

  2. poj3216 Prime Path(BFS)

    题目传送门  Prime Path The ministers of the cabinet were quite upset by the message from the Chief of Sec ...

  3. poj分类 很好很有层次感。

    初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      ( ...

  4. 【转】POJ题目分类推荐 (很好很有层次感)

    OJ上的一些水题(可用来练手和增加自信) (poj3299,poj2159,poj2739,poj1083,poj2262,poj1503,poj3006,poj2255,poj3094)初期: 一. ...

  5. 【转】ACM训练计划

    [转] POJ推荐50题以及ACM训练方案 -- : 转载自 wade_wang 最终编辑 000lzl POJ 推荐50题 第一类 动态规划(至少6题, 和 必做) 和 (可贪心) (稍难) 第二类 ...

  6. POJ 题目分类(转载)

    Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...

  7. (转)POJ题目分类

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

  8. acm常见算法及例题

    转自:http://blog.csdn.net/hengjie2009/article/details/7540135 acm常见算法及例题  初期:一.基本算法:     (1)枚举. (poj17 ...

  9. poj分类

    初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      ( ...

随机推荐

  1. Windows平台下为Python添加MySQL支持

    到Python官网下载MySQL-python-1.2.5.win32-py2.7.exe 安装MySQL-python-1.2.5.win32-py2.7 附 64位MySQL-python下载地址 ...

  2. cxgrid footer summary value by a column

    var AIndex: integer; AValue: variant; begin with cxGrid1DBTableView1.DataController.Summary do begin ...

  3. 一个基于python的即时通信程序

    5月17日更新: 广播信息.用户列表.信息确认列表以及通信信息,从原来的用字符串存储改为使用字典来存储,使代码更清晰,更容易扩展,具体更改的格式如下: 广播信息(上线): { 'status': 信息 ...

  4. Qt+MinGW+OpenCV开发环境在win7系统下的搭建(最新20140423)

    1 搭建环境 (1)联想Y470笔记本电脑,win7操作系统 (2)Qt 5.2.1 Open Source :(Qt Online installer for Window(9MB),即下载页面最上 ...

  5. windows 与fedora时间差

    windows 默认BIOS时间当前时间UTC+时区, 按北京时间时区,就是要加8个小时. Linux默认BIOS时间是UTC时间,所以同一机子上装WINDOWS与LINUX时间上会差8个小时.这问题 ...

  6. Sql查询除ID以外相同的数据

    id    NAME    AGE1    n1         12    n1         13    n2         24    n2         25    n22       ...

  7. 3123 高精度练习之超大整数乘法 - Wikioi

    题目描述 Description 给出两个正整数A和B,计算A*B的值.保证A和B的位数不超过100000位. 输入描述 Input Description 读入两个用空格隔开的正整数 输出描述 Ou ...

  8. @Entity设置实体lazy = false

    问题描述 在通过Hibernate查询Bean信息时报以下异常信息: org.hibernate.LazyInitializationException: could not initialize p ...

  9. css3实现非矩形图片效果

    经常在网站上看到有一些非矩形的图片展示.在以前可能我会毫不犹豫的直接放上张处理好的图片.但是这样的话确实有些不太友好.每每需要换图的时候,都要去开图像处理软件也是蛮拼的.自从有了css3的选装,妈妈就 ...

  10. replace()替换文字扑获组做法

    var txt = "12312131283", str = txt.replace(/(12(.3))/g,"中文$2");//$1是针对前面的扑获组()的如 ...