码迷,mamicode.com
首页 > 其他好文 > 详细

bzoj 1191

时间:2015-10-23 21:20:39      阅读:311      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

本来想打场uoj的,看到数论又跪了。。

还是二分图

技术分享
 1 #include<bits/stdc++.h>
 2 #define inc(i,l,r) for(i=l;i<=r;i++)
 3 #define dec(i,l,r) for(i=l;i>=r;i--)
 4 #define mem(a) memset(a,0,sizeof(a))
 5 #define inf 1e9
 6 #define ll long long
 7 #define succ(x) (1<<x)
 8 #define NM 2000+5
 9 using namespace std;
10 int read(){
11     int x=0,f=1;char ch=getchar();
12     while(!isdigit(ch)){if(ch==-)f=-1;ch=getchar();}
13     while(isdigit(ch))x=x*10+ch-0,ch=getchar();
14     return x*f;
15 }
16 struct edge{
17     int t;
18     edge *next;
19 }e[2*NM],*h[NM];
20 int n,m,i,t,k,v[NM],match[NM],s;
21 void add(int x,int y){
22     e[++s].t=y;e[s].next=h[x];h[x]=e+s;
23 }
24 bool dfs(int x){
25     for(edge *j=h[x];j;j=j->next)
26     if(v[j->t]!=i){
27         v[j->t]=i;
28         if(!match[j->t]||dfs(match[j->t])){
29             match[j->t]=x;
30             return true;
31         }
32     }
33     return false;
34 }
35 int main(){
36     m=read();n=read();
37     inc(i,1,n)
38     inc(k,1,2){
39         t=read();
40         add(i,n+t+1);
41     }
42     inc(i,1,n)
43     if(!dfs(i))break;
44     printf("%d\n",i-1);
45     return 0;
46 }
View Code

 

bzoj 1191

标签:

原文地址:http://www.cnblogs.com/onlyRP/p/4905688.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!