POJ1043 What's In a Name 逆图+完美匹配

题目链接:

poj1043




题意:

一个犯罪团伙有N个人,他们分别有一个名字和一个网名

现已知他们会先后进出一个房间发送电报

警方可以知道所有时间下:

进出房间的人的真实名字

同时通过截获该房间发出的电报,获得网名

问最后能否将所有真实名字和虚拟网名对上




解题思路:

首先根据题目条件名字和网名是一一对应的,可以大概确定是二分匹配中的完美匹配

然而根据样例很容易看出来,要想根据正确关系来建边是很复杂的

容易的做法是:每次将不可能匹配的名字和网名建边,最后根据补图进行最大匹配即可初步得出所有匹配关系.

但现在得到的最大匹配不一定是完美匹配

要确定某个名字和网名是匹配的 我们可以删除当前已匹配的边,再进行最大匹配

如果结果减小了,则一定是对应的

这样,依次枚举每一条最大匹配中的边.即可得出答案




代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define maxn 25
using namespace std;
struct node
{
    string a,b;
} s[maxn];
map<s
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Linux Administration: A Beginner's Guide, Fifth Edition Paperback: 662 pages Publisher: McGraw-Hill Osborne Media; 5 edition (September 23, 2008) Language: English ISBN-10: 0071545883 ISBN-13: 978-0071545884 Format: PDF You can buy this book: Amazon.com Description: Administering a Linux system isn't much like administering a Windows machine. Though the goals are similar and comparable problems arise under both environments, they each require administrators to adopt a certain way of thinking about processes and data. Linux Administration: A Beginner's Guide helps readers adapt their Windows experience to Linux work. Author Steve Shah does a great job of clueing Linux newcomers into the environment. His explanations are clear, patient, accurate, and useful, and they cover all aspects of the system administrator's job. He's careful to explain hundreds of commands in a logical way, including lists of options and examples of typical uses in many cases. But this is no mere command reference or novice's introduction. Shah doesn't shy away from explaining the really interesting aspects of Linux administration, including kernel compilation, Domain Name Service (DNS) configuration, sendmail setup, and establishing firewall protection with IP chaining. For all of these subjects (and many more), this book includes clear statements of what concepts are relevant, which commands to issue, and what to expect in response. It's a great help in self-guided explorations. It's also worth having this book on hand for work assignments--you'll find complete recipes for configuring all major Internet and local area network (LAN) services that also take into account easy maintenance and security.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值