# BZOJ 1934 Vote 善意的投票（最小割+二分图）

(1) 冲突数不大于 n:

(2) “同意”集合和“否定”集合之间的边全部是朋友关系
(3) 冲突是同意与不同意之间的割

  1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<cmath>
5 #include<algorithm>
6 #include<queue>
7 #include<vector>
8 #define LL long long
9 #define pii pair<int,int>
10 #define pll pair<long long,long long>
11 #define rep(i,a,b) for(int i=a;i<=b;i++)
12 #define per(i,a,b) for(int i=a;i>=b;i--)
13 #define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
14 #define bug cout<<"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"<<endl;
15 #define bugc(_) cout << (#_) << " = " << (_) << endl;
16 using namespace std;
17 const int N=1e6+5;
18 const int M=1e6+5;
19 const int INF=0x3f3f3f3f;
20
21 struct node{
22     int to,next,flow;
23 }edge[M*2];
24
25 int cnt,st,en;
27
28 void init(){
29     cnt=2;
31 }
32
33 void link(int u,int v,int flow){
38 }
39
40 int bfs(){
41     memset(dep,0,sizeof(dep));
42     dep[st]=1;
43     queue<int>q;
44     q.push(st);
45     while(!q.empty()){
46         int u=q.front();
47         q.pop();
49             node t=edge[i];
50             if(t.flow&&!dep[t.to]){
51                 dep[t.to]=dep[u]+1;
52                 q.push(t.to);
53             }
54         }
55     }
56     return dep[en];
57 }
58
59 int dfs(int u,int fl){
60     if(u==en) return fl;
61     int tmp=0;
63         node &t=edge[i];
64         if(t.flow&&dep[t.to]==dep[u]+1){
65             int x=dfs(t.to,min(t.flow,fl));
66             if(x>0){
67                 t.flow-=x;
68                 edge[i^1].flow+=x;
69                 tmp+=x;
70                 fl-=x;
71             }
72         }
73     }
74     if(!tmp) dep[u]=-2;
75     return tmp;
76 }
77
78 int dinic(){
79     int ans=0;
80     while(bfs()){
81         while(int d=dfs(st,INF)){
82             ans+=d;
83         }
84     }
85     return ans;
86 }
87
88 int main(){
89     int n,m;
90     while(~scanf("%d%d",&n,&m)){
91         init();
92         st=0,en=n+1;
93         for(int i=1;i<=n;i++){
94             int x;
95             scanf("%d",&x);
96             if(x==1)
98             else
100         }
101         for(int i=1;i<=m;i++){
102             int u,v;
103             scanf("%d%d",&u,&v);
111 }