BZOJ 1854 【Scoi2010】 游戏
Description
Input
Output
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define N 10010
#define M 1000010 using namespace std;
typedef long long llg; int n,pip[M],vis[M],cnt;
int head[N],next[M<<1],to[M<<1],tt; int getint(){
int w=0;bool q=0;
char c=getchar();
while((c>'9'||c<'0')&&c!='-') c=getchar();
if(c=='-') c=getchar(),q=1;
while(c>='0'&&c<='9') w=w*10+c-'0',c=getchar();
return q?-w:w;
} void link(int x,int y){to[++tt]=y;next[tt]=head[x];head[x]=tt;}
bool dfs(int u){
for(int i=head[u],v;i;i=next[i])
if(vis[to[i]]!=cnt){
v=to[i]; vis[v]=cnt;
if(!pip[v] || dfs(pip[v])){
pip[v]=u; return 1;
}
}
return 0;
} int main(){
n=getint();
for(int i=1;i<=n;i++)
link(getint(),i),link(getint(),i);
for(int i=1;i<=10000;i++){
cnt++;
if(!dfs(i)){
printf("%d",i-1);
return 0;
}
}
printf("10000");
}
BZOJ 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: 2672 Solved: 958[Submit][Status][ ...
 - ●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.二分图匹配: 首先我们发现每件装备只能在两种属性中选一种.因此,我们以每 ...
 - bzoj 1854: [Scoi2010]游戏
		
#include<cstdio> #include<iostream> #include<cstring> #define M 2000008 using name ...
 - BZOJ 1854: [Scoi2010]游戏 [连通分量 | 并查集 | 二分图匹配]
		
题意: 有$n \le 10^6$中物品,每种两个权值$\le 10^4$只能选一个,使得选出的所有权值从1递增,最大递增到多少 一开始想了一个奇怪的规定流量网络流+二分答案做法...然而我还不知道怎 ...
 - bzoj 1854: [Scoi2010]游戏【匈牙利算法】
		
没啥可说的,就是一边属性一边道具建二分图,把两个属性都连到道具上,然后枚举匹配,如果无法匹配就输出,时间戳优化 #include<iostream> #include<cstdio& ...
 - 【BZOJ】1854: [Scoi2010]游戏【二分图】
		
1854: [Scoi2010]游戏 Time Limit: 5 Sec Memory Limit: 162 MBSubmit: 6759 Solved: 2812[Submit][Status] ...
 
随机推荐
- Android 中MyApplication
			
package liu.basedemo; import android.app.Activity; import android.app.Application; import java.lang. ...
 - ThinkPHP  空方法 显示
			
TP如果 一个控制器 没有一个方法 ,只要有一个模版,URL会对应显示模版名称. 例子 http://localhost/yiyunmap/map/test map控制器 并没有 test方法 但是 ...
 - log4j 实现只输入我们指定包的日志
			
#all logger output level is 'ERROR' and output position is stdout #so only write our project's DEBUG ...
 - Highcharts使用简例 + 异步动态读取数据
			
第一部分:在head之间加载两个JS库. <script src="html/js/jquery.js"></script> <script src= ...
 - python中mysqldb的用法
			
1.引入MySQLdb库 import MySQLdb 2.和数据库建立连接 conn=MySQLdb.connect(host="localhost",user="ro ...
 - 烂泥:mysql5.5数据库cmake源码编译安装
			
本文由秀依林枫提供友情赞助,首发于烂泥行天下. 以前也写过一篇有关mysql5.0源码编译的文章,该文章为<烂泥:mysql5.0数据库源码编译安装>.但是MySQL自5.5版本以后,就开 ...
 - node.js表单——formidable
			
node处理表单请求,需要用到formidable包.安装formidable包的命令如下: npm install formidable 安装package的路径分为两种,一种是本地目录,一种是全局 ...
 - hdu 4960 Another OCD Patient(dp)
			
Another OCD Patient Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Ot ...
 - 【零基础学习iOS开发】【转载】
			
原文地址:http://www.cnblogs.com/mjios/archive/2013/04/24/3039357.html 本文目录 一.什么是iOS 二.主流手机操作系统 三.什么是iOS开 ...
 - Linux 下从头再走 GTK+-3.0 (二)
			
仅仅创建一个空白窗口是不够的,下面我们为创建的窗口添加一个按钮. 以 Hello,World!为例. 首先创建一个源文件:example2.c 内容如下. #include <gtk/gtk.h ...