就类似增广路那么做
把边看成点
每次肯定是选一条已选未选交替出现的路
j-i-k这样的一段//i已选
例如G1上去掉i可加入j,G2上去掉i可加入k
边aG1可加,G2去b可加
边cG1去b可加,G2去d可加
。。。
边 xxx G1去 yyy 可加,G2可加
找个顺序连边就行
直接可以加入的点连上源汇
注意顺序和连源汇的关系
#include<bits/stdc++.h>
#define file(KSCN) freopen(KSCN".in","r",stdin),freopen(KSCN".out","w",stdout)
using namespace std;
typedef long long ll;
namespace IO{
const int ios=1<<17;
char R[ios],*Rc=R,*RB=R;int pass;
inline int gec(){return(Rc==RB&&(RB=(Rc=R)+fread(R,1,ios,stdin),Rc==RB))?EOF:*Rc++;}
template<typename Tp>inline int read(Tp&A){
static int c,sg;c=gec();sg=0;A=0;
while(!isdigit(c)&&c!=EOF)sg|=(c=='-'),c=gec();
if(c==EOF)return EOF;
while(isdigit(c))A=(A<<3)+(A<<1)&