poj 3692 最大独立点集
来源:互联网 发布:php获取时间 编辑:程序博客网 时间:2024/05/29 19:14
题意:男同学间相互认识,女同学间相互认识,再给男女之间的认识关系,找一个集合,使选择的男女之间都相互认识
解法:如果以“认识”关系连线,在左右结合间都会连线,有背于二分图的含义,(线段的一个顶点在左集合,一个在右集合),所以我们可以以“不认识”关系连线,这样就得到了两个合理的集合,以给出的信息补集连线~
最大独立点集=定点数(|x+y|)-最大匹配数
/*---------------------------------- Love is more than a word. It says so much. When I see these four letters, I almost feel your touch. This is only happened since I fell in love with you. Why this word does this, I haven't got a clue. To My Goddess CY----------------------------------*/#include<iostream>#include<cstring>#include<algorithm>#include<cstdlib>#include<vector>#include<cmath>#include<stdlib.h>#include<iomanip>#include<list>#include<deque>#include<map>#include <stdio.h>#include <queue>#define maxn 250+5#define ull unsigned long long #define ll long long#define reP(i,n) for(i=1;i<=n;i++) #define REP(i,a,b) for(i=a;i<=b;i++) #define rep(i,n) for(i=0;i<n;i++)#define cle(a) memset(a,0,sizeof(a)) #define clehead(a) rep(i,maxn)a[i]=-1/* The time of story : ** while(1) { once upon a time, there was a mountain, on top of which there was a temple, in which there was an old monk and a little monk. Old monk was telling stories inside the temple. What was he talking about? ** } ÎûÎû (*^__^*)*/#define sci(a) scanf("%d",&a) #define scd(a) scanf("%lf",&a) #define pri(a) printf("%d",a) #define prie(a) printf("%d\n",a) #define prd(a) printf("%lf",a) #define prde(a) printf("%lf\n",a) #define pre printf("\n")#define LL(x) x<<1 #define RR(x) x<<|1#define pb push_back#define mod 90001#define PI 3.141592657const ull INF = 1LL << 61;const int inf = int(1e5)+10;const double eps=1e-5;using namespace std;struct node{ int u,v,w; int next;};bool cmp(int a,int b){ return a>b;}bool bmap[maxn][maxn];bool bmark[10000];int nx,ny;int cx[10000];int cy[10000];int m,g,b;int findpath(int u){ int i,j,k; rep(i,ny){ if(bmap[u][i]&&!bmark[i]){ bmark[i]=1; if(cy[i]==-1||findpath(cy[i])) { cy[i]=u; cx[u]=i; return 1; } } } return 0;}int maxmatch(){ int i,j,k; int res(0); rep(i,nx)cx[i]=-1; rep(j,ny)cy[j]=-1; rep(i,nx){ if(cx[i]==-1){ rep(j,ny)bmark[j]=0; res+=findpath(i); } } return res;}int main(){ freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int T=0; while(cin>>g>>b>>m) { if(m+g+b==0)break; int i,j,k; memset(bmap,true,sizeof(bmap)); nx=g,ny=b; rep(i,m) { int x,y; cin>>x>>y; bmap[x-1][y-1]=false; } printf("Case %d: ",++T); cout<<nx+ny-maxmatch()<<endl; } return 0;}
0 0
- POJ 3692 Kindergarten ( 最大独立点集 )
- poj 3692 最大独立点集
- POJ 3692 - Kindergarten 二分图的最大独立点集
- Poj 3692 Kindergarten 二分图最大独立点集
- POJ 3692 二分图最大点独立集 解题报告
- poj 2771 最大独立点集
- poj 1466 最大独立点集
- POJ 1466 最大独立点集
- POJ 3692 最大独立集
- poj 3692 Kindergarten(最大独立点集 + 二分图最大匹配)
- 最大点独立集
- POJ 1466 Girls and Boys(最大独立点集)
- POJ 1466 Girls and Boys (最大独立点集)
- POJ 2771 Guardian of Decency(最大独立点集)
- POJ 1466 Girls and Boys(最大独立点集)
- POJ 3692:Kindergarten 求补图的最大点独立集 头一次接触这样的做法
- POJ 3692 Kindergarten(最大独立集)
- POJ 3692 Kindergarten (最大独立集)
- linux软件管理器
- C++中Vector的常见使用方法
- java io重定向
- Python yield 使用浅析
- (二)正则表达式之常用表达式详细解析
- poj 3692 最大独立点集
- BFS模板
- WPF一些概念的区别
- ZOJ-1275
- codeforces 453A Little Pony and Expected Maximum 最大值期望
- 第四章 树(二)
- SDL2.0+ffmpeg2.3
- HDU 3695 Computer Virus on Planet Pandora AC自动机
- 01背包使用滚动数组优化详细讲解