【二分匹配】 poj2060 Taxi Cab Scheme

『杭电1960』Taxi Cab Scheme #include<stdio.h> #include<string.h> #define N_node 500 + 50 #define N_edge 300000 typedef struct { int to ,next; }STAR; typedef struct { int t; int xs ,xe ,ys ,ye; int time; }NODE; STAR E[N_edge]; NODE node[N_node]; int li... 阅读详情
Taxi Cab Scheme

Description

Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up the customers calling to get a cab as soon as possible,there is also a need to schedule all the taxi rides which have been booked in advance.Given a list of all booked taxi rides for the next day, you want to minimise the number of cabs needed to carry out all of the rides. 
For the sake of simplicity, we model a city as a rectangular grid. An address in the city is denoted by two integers: the street and avenue number. The time needed to get from the address a, b to c, d by taxi is |a - c| + |b - d| minutes. A cab may carry out a booked ride if it is its first ride of the day, or if it can get to the source address of the new ride from its latest,at least one minute before the new ride's scheduled departure. Note that some rides may end after midnight.

Input

On the first line of the input is a single positive integer N, telling the number of test scenarios to follow. Each scenario begins with a line containing an integer M, 0 < M < 500, being the number of booked taxi rides. The following M lines contain the rides. Each ride is described by a departure time on the format hh:mm (ranging from 00:00 to 23:59), two integers a b that are the coordinates of the source address and two integers c d that are the coordinates of the destination address. All coordinates are at least 0 and strictly smaller than 200. The booked rides in each scenario are sorted in order of increasing departure time.

Output

For each scenario, output one line containing the minimum number of cabs required to carry out all the booked taxi rides.

Sample Input

2
2
08:00 10 11 9 16
08:07 9 16 10 11
2
08:00 10 11 9 16
08:06 9 16 10 11

Sample Output

1
2

题意:给出乘客的起始时间,起点和目的地的坐标,求最少要几辆的士能满足所有的乘客的出行。


#include<cstdio>
#include<cstring>
using namespace std;
#define MAX 505
#define abs(x) ((x)>0?(x):(-(x)))
//这里的括号一定不能省
int time[MAX],pos[MAX][4];
bool path[MAX][MAX],visit[MAX];
int match[MAX];
bool SearchPath(int s,int m)
{
    for(int i=0; i<m; ++i)
    {
        if(path[s][i]&&!visit[i])
        {
            visit[i]=true;
            if(match[i]==-1||SearchPath(match[i],m))
            {
                match[i]=s;
                return true;
            }
        }
    }
    return false;
}
int distants(int a,int b,int c,int d)
{
    return (abs(a-c)+abs(b-d));
}
int main()
{
    int T,n,a,b;
    scanf("%d",&T);
    for(;T--;)
    {
        scanf("%d",&n);
        memset(path,false,sizeof(path));
        for(int i=0;i<n;++i)
        {
            scanf("%d:%d",&a,&b);
            time[i]=a*60+b;
            for(int j=0;j<4;++j)
                 scanf("%d",&pos[i][j]);
        }
        for(int i=0;i<n;++i)
        {
            for(int j=i+1;j<n;++j)
            {
                if(time[i]+distants(pos[i][0],pos[i][1],pos[i][2],pos[i][3])+distants(pos[i][2],pos[i][3],pos[j][0],pos[j][1])<time[j])
                    path[i][j]=true;
            }
        }
        int summ=0;
        memset(match,-1,sizeof(match));
        for(int i=0; i<n; ++i)
        {
            memset(visit,false,sizeof(visit));
            if(SearchPath(i,n))
                summ++;
        }
        printf("%d\n",n-summ);
    }
    return 0;
}

来源: http://blog.youkuaiyun.com/acm_ted/article/details/7780079

Cursor集成Claude 4.6免费版:本地IDE合规调用指南 大语言模型编程助手(LLM Copilot)已成为现代开发标配,其核心能力依赖于上下文理解、代码推理与结构化输出等关键技术原理。Anthropic官方提供的Claude系列模型,尤其Claude 4.6,凭借200K超长上下文、tool use函数调用和严格可控的API设计,在工程实践中展现出显著技术价值。该能力可无缝嵌入本地IDE环境,支撑代码解释、跨文件分析、单元测试生成等高频开发场景。本文聚焦Cursor这一开源可审计IDE,详解如何合规复用Anthropic免费tier接口(/v1/messages 阅读详情

相关推荐

三大主流交易接口实战指南:XTP、CTP与数字货币API的实盘接入解析

本文深入解析了量化交易系统实现实盘交易的关键环节,聚焦于三大主流交易接口的实战接入。详细介绍了证券领域的XTP、期货领域的CTP以及数字货币交易所API的核心特性、代码封装要点与风控实践,并提供了多市场接口整合的统一架构方案,为开发者打通量化交易的“最后一公里”提供了一份接地气的实战指南。

win55的博客 1377

Taxi Cab Scheme(最小路径覆盖)

Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up the customers calling to get a cab as soon as possible, the...

qq_41006240的博客 296

Uniapp+Vue3+Monorepo:如何优化你的前端开发流程(附完整配置代码)

本文详细介绍了如何利用Uniapp+Vue3+Monorepo技术栈优化前端开发流程,提升代码可维护性和团队协作效率。通过Monorepo架构实现依赖管理智能化、代码复用最大化和构建流程统一化,结合完整配置代码和实战指南,帮助开发者快速构建高性能跨端应用。

weixin_29011993的博客 453

Taxi Cab Scheme———最小路径覆盖

Description Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up the customers calling to get a cab as soon as

qq_21820377的专栏 573

Delta机器人:运动学正反解分析

Delta机器人:运动学正反解分析 一、Delta机构简介 Delta机构是并联机构中的一种典型机构,起原始结构如图1所示。Delta机构由R.Clavel 博士在 1985年发明,是现在并联机器人中使用最多的一种,具备了并联机构所特有的优点,负载能力强、效率高、末端执行器精度高、运动惯性小,可以高速稳定运动等。因此在机器人领域获得了越来越广泛的应用。以实现高速、精准、高效的运动。           &n

花洛兮灬 3万+

关于Oxford Radar RobotCar Dataset的学习笔记

https://oxford-robotics-institute.github.io/radar-robotcar-dataset/documentation 简介 雷达是 Navtech CTS350-X 调频连续波 (FMCW) 扫描雷达,在所使用的配置中提供 4.38 cm 的距离分辨率和 0.9 度的旋转分辨率,范围高达 163 m,同时提供对天气条件的稳健性这可能会给其他传感器模式带来麻烦。在其他配置中,Navtech CTS350-X 可以提供超过 650 m 的范围和更高的旋转速度。然而,对

禾烁的博客 5297

n个点最小覆盖圆c语言编程,最小点覆盖 POJ 2060 Taxi Cab Scheme

Taxi Cab SchemeTime Limit:1000MSMemory Limit:30000KTotal Submissions:1342Accepted:587DescriptionRunning a taxi station is not all that simple. Apart from the obvious demand for a centralised coordinat...

weixin_42512103的博客 279

《QGIS快速入门与应用基础》009:国内镜像源(清华大学/阿里云)下载技巧

针对国内用户下载QGIS速度慢、易中断的问题,推荐使用清华大学和阿里云两大国内镜像源,提供3-10MB/s的极速下载方案。详细解析镜像源核心优势、分步骤下载指南及校验方法,对比清华(同步快、北方优选)与阿里云(南方节点多)的特点。针对常见问题如版本延迟、404错误等提供解决方案,并介绍搭配IDM等工具实现多线程加速的进阶技巧。通过镜像源+下载工具组合,用户可高效获取QGIS安装包,为后续系统安装奠定基础。

LuckyHanMo的博客 1741

Taxi Cab Scheme(不可重复利用最小路径覆盖)

Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up the customers calling to get a cab as soon as possible, ther...

FIVE 345

大数据在电力行业的应用案例解析-【电力技术】(九)大数据在电力储能运维中的深度应用(含故障预测代码)

大数据技术为电力储能运维提供了“精准化、智能化、高效化”的解决方案,破解了传统运维的核心痛点,实现了储能系统从“被动抢修”到“主动运维”的转型,为新型电力系统建设提供了重要支撑。当前,随着储能产业的快速发展,大数据与储能运维的融合将更加深入,未来将结合人工智能、物联网、区块链等技术,实现储能运维的全流程智能化——从设备故障的提前预警,到寿命的精准预测,再到运维策略的自动优化、调度协同的实时响应,进一步提升储能系统的安全性、经济性与可靠性。

getusushu的博客 88

UI渲染顺序:合批为何被拆碎?

在 Hierarchy 中,避免出现:Image(列表1) → Text(列表1) → 特效 → Image(列表2) → Text(列表2)…若可行,在逻辑上把布局组织成“同类元素集中”:例如:列表行中,Image 集中、Text 集中;或者接受 Text 本身就拆出一批,关键是不要在 Text 中间再插入别的材质。现实中不一定能做到完美的“所有 Image 连在一起”,但你会有一个意识:同一 Canvas 内,如果你把不同材质的元素交错穿插,

本博客聚焦游戏开发技巧、创业实战心得及大学热门课程干货。这里既有技术深度,也有思维广度,无论你是开发者、创业者还是高校学子,都能在这里找到适合自己的成长之路! 85

poj 2060 Taxi Cab Scheme (二分匹配)

Taxi Cab Scheme Time Limit:1000MS Memory Limit:30000K Total Submissions:5710 Accepted:2393 Description Running a taxi station is not all that simple. A...

anque1234的博客 198

数据科学助力大数据领域的航空安全分析

随着航空业的快速发展,航班数量不断增加,航空安全问题日益受到关注。大数据时代的到来,使得航空领域积累了大量的数据,包括飞行数据、维护数据、气象数据等。本文章的目的在于探讨如何运用数据科学的方法和技术,对这些大数据进行分析,以提高航空安全水平。范围涵盖了从数据收集、预处理到数据分析、模型构建和应用的整个流程。本文将按照以下结构进行组织:首先介绍数据科学和航空安全分析的核心概念以及它们之间的联系;接着阐述核心算法原理和具体操作步骤,并使用Python源代码进行详细说明;

软件工程实践的博客 1292

poj 2060 Taxi Cab Scheme 二分匹配匈牙利

题意:有n个任务,从a点到b点,如果一辆车在a点的下个任务开始时间前一分钟可以返回a点的话则可以继续下个任务,求完成所有任务所需要的最少车的数目:            思路:最少路径覆盖,如果两个任务可以用一辆车完成的话,则连一条边,最后由m-最大匹配数得到结果。            代码:   #include #include #include #include #include #

a1ways_online的专栏 415

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

Substrate_bip39适配鸿蒙:跨平台密钥管理实践

BIP39作为区块链钱包的核心标准,通过助记词实现确定性密钥派生,保障加密资产安全。其技术原理基于分层确定性钱包(HD Wallet)架构,结合PBKDF2等加密算法实现种子派生。在跨平台开发中,保持密钥派生一致性尤为关键,特别是涉及国密算法(SM2/SM3/SM4)时。通过Flutter的FFI机制将substrate_bip39适配到鸿蒙系统,开发者可构建统一的安全密钥管理体系,有效解决多平台兼容性问题。该方案在分布式安全子系统、抗侧信道攻击等鸿蒙特有功能上有显著优势,适用于数字钱包、身份认证等需要跨平

weixin_33868027的博客 390

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

poj 2060 Taxi Cab Scheme (二分匹配)

Problem Description Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up the customers calling to get a cab as s

hndu__lz的博客 389

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

POJ 2060-Taxi Cab Scheme

Description Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up the customers calling to get a cab as soon as p

jjs98 630

poj 2060 Taxi Cab Scheme 最小路径覆盖

//二分匹配的最小路径覆盖 //对于第i次ride,如果在第i次ride结束后还能在第j次ride出发前赶到第j次的出发点 //那么i到j就有一条边 //根据最小路径覆盖 = N - 最大匹配即可得到答案 #include #include #include #include using namespace std; const int maxn  = 510; int lin

ijbuhv的专栏 734

HDU 1350 & HDU 1960 & POJ 2060 Taxi Cab Scheme【二分图之最小路径覆盖,经典】

题意:样例1中: 8:00的时候要把第一位乘客从(10,11)送到(9,16),花费时间为6min(即曼哈顿距离)。 这辆车可以在(9,16)等到08:07 的时候送第二名乘客到达目的地。 而样例2中,第二名乘客08:06就要出发,而第一辆车08:06才到,所以要重新派一辆车。因为题目中说"The booked rides in each scenario are sorted in order of increasing departure time." 这道题很难想到是二分匹配的最小路径覆盖。 想到的话

AC_Dreameng 678

POJ2060 Taxi Cab Scheme(最小路径覆盖)

题意:有 n 个乘客需要乘出租车出行,给出他们出发时间,出发地点,目的地(input 保证数据按照出发时间升序给出),问最少需要安排多少辆车才能满足他们的需求。 思路:我们把每个乘客的旅程看成一个点,那么如果去搭载第 i 个人的车在把第 i 个人送到目的地后,立即启程去第 j

laoda扯一扯 1608

POJ2060-Taxi Cab Scheme (最小路径覆盖)

Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up the customers calling to get a cab as soon as possible, ther

swust5120160705的博客 658

POJ-2060 Taxi Cab Scheme 最小路径覆盖(匈牙利)

锻炼一下自己的邻接表建图能力。。。然后就是taoban

聂小白的专栏 554

二分匹配题集

普通匹配,多重匹配 【HDU】 1068 Girls and Boys 最大匹配★ 1150 Machine Schedule 最小点覆盖★ 1151 Air Raid 最小路径覆盖★ 1179 Ollivanders 最大匹配★ 1281 棋盘游戏 行列匹配+求关键点★★ 1498 50 years, 50 colors 行列匹配★ 1507 Uncle Tom's Inhe

夏天的风 5609

Hdu 1350 Taxi Cab Scheme (匈牙利 + 最小路径覆盖)

题意:明天有m名客人从城市不同位置出发,达到目的地,已知每个人的出发时间,出发地点和目的地,你的任务是用最少的出租车送他们。从一个点到令一个点的所用时间是他们的曼哈顿距离。接送某乘客要提前到一分钟。 思路:这个DAG最小路径覆盖经典问题,可以把这n个乘客构造成一张二分图,如果在接送完A乘客还有时间接送B乘客,就在二分图中连接一条从A到B的边。然后最小路径覆盖的答案就是n(乘客总数)-最大匹配。...

我是蒋卫升呀~ 258

Taxi Cab Scheme 【HDU - 1350】【匈牙利算法解决最小链覆盖】

题目链接 这道题用以理解匈牙利算法是一道很不错的题。先讲讲题意吧。 题意:有N个人,他们在特定的时间(hour : minute)要从地点(a, b)前往地点(c, d),然后呢,我们如果说前一个人i的出租车可以开回来再接j这个人,那么他们就可以少叫一辆出租车了。现在,题目想知道最少的需求的出租车的个数。 思路:看到这样的问题的时候,很容易让人想到最小链覆盖等于最长反链这样一个性...

既然弱小,就只顾变强就是了 431

Taxi Cab Scheme

原题构图+简单路径覆盖#include #include #define MAXN 510using namespace std ;struct Ride{ int minutes , a , b , c , d , cost ;} ;struct Graph{ int v , next ;};Graph G[MAXN * MAXN] ;

x_chaos的专栏 534
上一篇: 【二分匹配】 hdu1083 Courses
下一篇: 【线段树】 hdu1698 Just a Hook
ACM_Ted
博客等级 码龄15年 122粉丝 208原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值