bzoj1854[Scoi2010]游戏
来源:互联网 发布:linux和windows的优劣 编辑:程序博客网 时间:2024/04/30 09:24
明显的二分图最大匹配,但是N到了1000000,,所以我们在原来的做法上加一点改动
我们有几种方法:
1使用bitset大法避免memset癌
2我们可以把y数组开成int类型,这样我们就可以变成y[e[i].y]!=T,T是第几次匹配
3时间戳大法,然而并没能看懂
这道题还有丧心病狂的并查集大法,详情请见:hzwer
#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#include<cstdlib>#include<algorithm>#include<bitset>#define LL long long #define fo(i,a,b) for(int i=a;i<=b;i++)#define efo(i,x) for(int i=last[x];i!=0;i=e[i].next)using namespace std;inline LL read(){LL d=0,f=1;char s=getchar();while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}while(s>='0'&&s<='9'){d=d*10+s-'0';s=getchar();}return d*f;}#define N 1010005struct edge{int y,next;}e[N*2];int l[N]={0},last[N]={0},ne=0;bitset<N>y;int n;void add(int x,int y){e[++ne].y=y;e[ne].next=last[x];last[x]=ne;}bool match(int x){efo(i,x)if(y[e[i].y]==0){y[e[i].y]=1;if(l[e[i].y]==0||match(l[e[i].y])){l[e[i].y]=x;return 1;}}return 0;}int main(){n=read();fo(i,1,n){int x=read(),y=read();add(x,i);add(y,i);}fo(i,1,10001){y.reset();if(match(i)==0){cout<<i-1<<endl;return 0;}}return 0;}
0 0
- bzoj1854 [Scoi2010]游戏
- bzoj1854[Scoi2010]游戏
- bzoj1854[Scoi2010]游戏
- BZOJ1854 [Scoi2010]游戏
- BZOJ1854: [Scoi2010]游戏
- 【bzoj1854】[Scoi2010]游戏
- BZOJ1854: [Scoi2010]游戏
- bzoj1854[Scoi2010] 游戏
- 【bzoj1854】[Scoi2010]游戏
- bzoj1854: [Scoi2010]游戏
- 【bzoj1854】[Scoi2010]游戏
- [bzoj1854][Scoi2010]游戏
- bzoj1854 [Scoi2010]游戏
- bzoj1854 [Scoi2010]游戏
- BZOJ1854: [Scoi2010]游戏
- BZOJ1854: [Scoi2010]游戏
- [BZOJ1854][Scoi2010]游戏
- 【bzoj1854】 SCOI2010游戏 二分图匹配
- 2015-12-13复习之CSS3选择器
- 补码
- C语言总结
- HDU 1342 Lotto
- btrfs 使用指南 - 1 概念,创建,块设备管理,性能优化
- bzoj1854[Scoi2010]游戏
- Company A面试 笔试 : 爬山 算步骤 问题
- servlet复习(二)HTTP Servlet API
- 使用golang的标准库搭建网站--3.模板函数
- 三大图片缓存库对比
- 通过wireshark,以及python代码收发邮件,了解smtp协议,pop协议工作过程
- LeetCode(110) Balanced Binary Tree解题报告
- androidstudio Error:(1, 1) 错误: 非法字符: '\ufeff' 解决办法
- android studio连接不上真机