1854: [Scoi2010]游戏
1854: [Scoi2010]游戏
Time Limit: 5 Sec Memory Limit: 162 MB
Submit: 2538 Solved: 905
[Submit][Status]
Description
Input
Output
Sample Input
1 2
3 2
4 5
Sample Output
HINT
【数据范围】
对于30%的数据,保证N < =1000
对于100%的数据,保证N < =1000000
Source
题解:此题一拿到,不难发现是一个比较明显的二分图匹配,可是如phile神犇所言(orzPhile2333),匈牙利算法的时间复杂度为O(NM),可是此题中实际上N<=10000 M<=1000000,这不是必死无疑的节奏么——可是貌似裸的匈牙利算法还是妥妥Accept了。。。so神奇。。。求高人解释
/**************************************************************
Problem:
User: HansBug
Language: Pascal
Result: Accepted
Time: ms
Memory: kb
****************************************************************/ type
point=^node;
node=record
g:longint;
next:point;
end; var
i,j,k,l,m,n,pt:longint;
c,f:array[..] of longint;
a:array[..] of point;
function min(x,y:longint):longint;inline;
begin
if x<y then min:=x else min:=y;
end;
procedure add(x,y:longint);inline;
var p:point;
begin
new(p);
p^.g:=y;
p^.next:=a[x];
a[x]:=p;
end;
function check(x:longint):boolean;inline;
var p:point;
begin
p:=a[x];
while p<>nil do
begin
if f[p^.g]<>pt then
begin
f[p^.g]:=pt;
if c[p^.g]= then
begin
c[p^.g]:=x;
exit(true);
end
else if check(c[p^.g]) then
begin
c[p^.g]:=x;
exit(true);
end;
end;
p:=p^.next;
end;
exit(false);
end;
begin
readln(n);
for i:= to n do a[i]:=nil;
for i:= to n do
begin
readln(j,k);
add(j,i);add(k,i);
end;
fillchar(c,sizeof(c),);
fillchar(f,sizeof(f),);
pt:=;
for i:= to do
begin
inc(pt);
if not(check(i)) then
begin
writeln(i-);
halt;
end;
end;
writeln();
end.
1854: [Scoi2010]游戏的更多相关文章
- BZOJ 1854: [Scoi2010]游戏 无向图判环
题目链接: 题目 1854: [Scoi2010]游戏 Time Limit: 5 Sec Memory Limit: 162 MB 问题描述 lxhgww最近迷上了一款游戏,在游戏里,他拥有很多的装 ...
- BZOJ 1854: [Scoi2010]游戏( 二分图最大匹配 )
匈牙利算法..从1~10000依次找增广路, 找不到就停止, 输出答案. --------------------------------------------------------------- ...
- 【BZOJ】1854: [Scoi2010]游戏【二分图】
1854: [Scoi2010]游戏 Time Limit: 5 Sec Memory Limit: 162 MBSubmit: 6759 Solved: 2812[Submit][Status] ...
- BZOJ 1854: [Scoi2010]游戏 并查集
1854: [Scoi2010]游戏 Time Limit: 5 Sec Memory Limit: 162 MBSubmit: 2672 Solved: 958[Submit][Status][ ...
- 1854: [Scoi2010]游戏[并查集]
1854: [Scoi2010]游戏 Time Limit: 5 Sec Memory Limit: 162 MBSubmit: 4938 Solved: 1948[Submit][Status] ...
- 【BZOJ】1854: [Scoi2010]游戏
http://www.lydsy.com/JudgeOnline/problem.php?id=1854 题意:n个数据,每个数据有两个属性,要求取一些数据且每个数据取一个属性使得组成连续的一段单调递 ...
- ●BZOJ 1854 [Scoi2010]游戏
题链: http://www.lydsy.com/JudgeOnline/problem.php?id=1854 题解: 并查集(还可以用匈牙利算法进行单路增广的二分图匹配) 把每个武器看成是一条边, ...
- bzoj 1854: [Scoi2010]游戏 (并查集||二分图最大匹配)
链接: https://www.lydsy.com/JudgeOnline/problem.php?id=1854 写法1: 二分图最大匹配 思路: 将武器的属性对武器编号建边,因为只有10000种 ...
- BZOJ 1854: [Scoi2010]游戏(二分图匹配/并查集)
题面: https://www.lydsy.com/JudgeOnline/problem.php?id=1854 题解: 1.二分图匹配: 首先我们发现每件装备只能在两种属性中选一种.因此,我们以每 ...
随机推荐
- TortoiseSVN使用简介
TortoiseSVN使用简介 2009-04-24 来源: dev.idv.tw 1.安装及下载client 端 2.什么是SVN(Subversion)? 3.为甚么要用SVN? 4.怎么样在Wi ...
- Windows 7 下 PHP 开发环境搭建(手动)
Windows 7 下 PHP 开发环境搭建 1.说明 做开发的都知道一句话,就是“站在巨人的肩膀上”.确实现在打开浏览器随便一搜很多一键安装PHP环境的软件,比如wamp.xampp.AppServ ...
- 如何在鼠标hover时改变标注的样式
如何在鼠标hover时改变标注的样式? ---------------- 教程 ----------------------- 首先创建1张地图 //初始化地图对象,加载地图 var map ...
- Professional C# 6 and .NET Core 1.0 - What’s New in C# 6
本文为转载,学习研究 What's New in C# 6 With C# 6 a new C# compiler is available. It's not only that a source ...
- API网关Ocelot 使用Polly 处理部分失败问题
在实现API Gateway过程中,另外一个需要考虑的问题就是部分失败.这个问题发生在分布式系统中当一个服务调用另外一个服务超时或者不可用的情况.API Gateway不应该被阻断并处于无限期等待下游 ...
- ECMAScript 6 笔记(五)
Iterator和for...of循环 1. Iterator(遍历器)的概念 Iterator接口的目的,就是为所有数据结构,提供了一种统一的访问机制,即for...of循环 遍历器(Iterato ...
- 谨慎能捕千秋蝉(三)——界面操作劫持与HTML5安全
一.界面操作劫持 1)ClickJacking ClickJacking点击劫持,这是一种视觉上的欺骗. 攻击者使用一个透明的.不可见的iframe,覆盖在网页的某个位置上,诱使用户点击iframe. ...
- 【Scala】Scala之Classes and Properties
一.前言 前面学习了控制结构,下面学习Scala的Class和Properties. 二.Class&Properties 尽管Scala和Java很类似,但是对类的定义.类构造函数.字段可见 ...
- iptables禁止ping入
iptables禁止ping入 以下设置将允许自己往外ping 不允许别人ping自己 vi /etc/sysconfig/iptables 加入如下2条规则 -A INPUT -p icmp --i ...
- linux挂载本地windows分区或目录
linux挂载本地windows分区或目录 一.linux挂载本地windows硬盘分区 向虚拟机Centos添加本地windows硬盘 注:(添加物理硬盘后,在centos操作会直接写入本地硬盘) ...