hdu1151Air Raid
Air Raid
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2704 Accepted Submission(s): 1762
With these assumptions your task is to write a program that finds the minimum number of paratroopers that can descend on the town and visit all the intersections of this town in such a way that more than one paratrooper visits no intersection. Each paratrooper lands at an intersection and can visit other intersections following the town streets. There are no restrictions about the starting intersection for each paratrooper.
no_of_intersections
no_of_streets
S1 E1
S2 E2
......
Sno_of_streets Eno_of_streets
The first line of each data set contains a positive integer no_of_intersections (greater than 0 and less or equal to 120), which is the number of intersections in the town. The second line contains a positive integer no_of_streets, which is the number of streets in the town. The next no_of_streets lines, one for each street in the town, are randomly ordered and represent the town's streets. The line corresponding to street k (k <= no_of_streets) consists of two positive integers, separated by one blank: Sk (1 <= Sk <= no_of_intersections) - the number of the intersection that is the start of the street, and Ek (1 <= Ek <= no_of_intersections) - the number of the intersection that is the end of the street. Intersections are represented by integers from 1 to no_of_intersections.
There are no blank lines between consecutive sets of data. Input data are correct.
4
3
3 4
1 3
2 3
3
3
1 3
1 2
2 3
1
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
const int maxn = 120+10;
vector<int> G[maxn];
int from[maxn], tot;
bool use[maxn];
int gn, gm;
//Accepted 1151 0MS 332K 1104 B G++ Achiberx
bool match(int x) {
for(int i = 0; i < (int)G[x].size(); i++) {
int v = G[x][i];
if(!use[v]) {
use[v] = true;
if(from[v] == -1 || match(from[v])) {
from[v] = x;
return true;
}
}
}
return false;
} int hungary() {
tot = 0;
memset(from, -1, sizeof(from));
for(int i = 1; i <= gn; i++) {
memset(use, false, sizeof(use));
if(match(i)) tot++;
}
return tot;
} int main()
{
int T, u, v;
scanf("%d", &T);
while(T--) {
scanf("%d%d", &gn, &gm);
for(int i = 0; i < maxn; i++) G[i].clear();
for(int i = 1; i <= gm; i++) {
scanf("%d%d", &u, &v);
G[u].push_back(v);
}
int res = hungary();
printf("%d\n", gn-res);
} }
hdu1151Air Raid的更多相关文章
- HDU1151Air Raid(二分图的最大匹配)
题目大意: 有一个城镇,它的所有街道都是单行的,并且每条街道都是和两个路口相连.同时已知街道不会形成回路. 你的任务是编写程序求最小数量的伞兵,这些伞兵可以访问(visit)所有的路口.
- 一张“神图”看懂单机/集群/热备/磁盘阵列(RAID)
单机部署(stand-alone):只有一个饮水机提供服务,服务只部署一份 集群部署(cluster):有多个饮水机同时提供服务,服务冗余部署,每个冗余的服务都对外提供服务,一个服务挂掉时依然可用 热 ...
- 什么是RAID?RAID有什么用?RAID原理
什么是RAID 硬盘是个很脆弱的东西,它经常会坏掉.所以,为了保证服务器可靠耐用,硬盘必须时时刻刻保持可用.所以有了RAID这个东西.它的目的是将好几个硬盘合并在一起,就算硬盘坏了一个,剩下还有好几个 ...
- 3.raid基础应用
raid分为软备份和硬备份 软备份主要用来实验 应备份用于生产环境 raid0(带区卷) 具有很高的数据传输率,没有数据的冗余 1块磁盘 raid1(镜像卷) 提供数据冗余,利用率低 2块 ...
- linux基础-磁盘阵列(RAID)实例详解
磁盘阵列(RAID)实例详解 raid技术分类 软raid技术 硬raid技术 Raid和lvm的区别 为什么选择用raid RAID详解 RAID-0 RAID-1 RAID-5 Raid-10 R ...
- Dell R730 配置完RAID后装系统找不到硬盘。
1. 各硬盘只是灯都正常.硬件无故障. 2. 8个600G硬盘做的RAID0和RAID5后都在装系统选盘处找不到硬盘.(注意: 第一次做raid 时,没有进行初始化init.后补做也无效,一直复现这个 ...
- Linux学习之CentOS(二十八)--RAID原理基础及Linux下软件RAID配置
一.RAID的原理基础 在 讲解RAID的原理基础之前,我们首先来了解一下传统磁盘的劣势.我们知道一台PC机种都会包含CPU.内存.主板.硬盘.网卡等硬件,影响计算机性能的 组建包括:CPU.主板总线 ...
- Raid 介绍以及软raid的实现
RAID: old Redundant Arrays of Inexpensive Disks (廉价磁盘冗余阵列) new Redundant Arrays of Independent Disks ...
- Linux RAID卡优化
200 ? "200px" : this.width)!important;} --> 介绍 我们的生产服务器经常会做raid存储,但是单单做了raid就能保证性能高效和数据 ...
随机推荐
- Tortoisegit 记住用户名和密码
Tortoisegit 记住用户名和密码方法: [Windows系统] 当你配置好git后,在 C:\Documents and Settings\Administrator\ 目录下有一个 .gi ...
- PHP学习笔记10-图片加水印
先找好一张图片,更名为face.jpeg,创建watermark.php: <?php /** * Created by PhpStorm. * User: Administrator * Da ...
- 用jmeter进行多用户并发压力测试 [转]
近日manager要求对项目进行压力测试,开始对jmeter进行了研究.jmeter是Apache一个开源项目,可对各种项目进行测试,甚至包括junit. 测试要求如下,多用户同时登陆web应用程序, ...
- Objective-C 程序设计第四版
1,@class XYPoint; 写在.h文件里,告诉编译器有这类,然后用的时候,其实是在.m文件引入的. 例如.#import “XYPoint.h” 然后在.m文件里就能用XYPoint.h ...
- CBV进阶(一)
http_method_names , http_method_not_allowd 用途:views只接受这些请求. 范围View Default:['get', 'post', 'put', 'p ...
- [置顶] IT屌丝的离职申请
各位好,很遗憾在如此关键的时刻和大家说告别.我为金三也付出了近一年的心血,几乎没怎么休过令人舒心的周末,熬了多少夜更不用说,如此的离开,请相信我也非常心痛. 尽管直到现在我的水 ...
- JNI_Java Native Interface
一.简介 Java Native Interface(JNI),java与c/c++交互的接口,下面是一个简单是示例. javah 可以生成native方法对应的头文件,javap 可以查看方法或者属 ...
- poj 3281 Dining 网络流-最大流-建图的题
题意很简单:JOHN是一个农场主养了一些奶牛,神奇的是这些个奶牛有不同的品味,只喜欢吃某些食物,喝某些饮料,傻傻的John做了很多食物和饮料,但她不知道可以最多喂饱多少牛,(喂饱当然是有吃有喝才会饱) ...
- 1369 - Answering Queries(规律)
1369 - Answering Queries PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 32 M ...
- SQL查询各阶段的统计信息
我们经常会遇到各种分类统计问题,须要将这些结果一次显示出来.这次老师提出的要求是我想看60分下面多少人.60~70多少人,70~80多少人.80~90多少人,90~100多少人.他们曾 ...