# 【BZOJ4025】二分图

### 【题解思路】

（时间线段树）有关的题以后会补充上来的

### 【code】

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(k,i,j) for(int k = i;k <= j; ++k)
#define FOR(k,i,j) for(int k = i;k >= j; --k)
int x=0,f=1; char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0'; ch=getchar();}
return x*f;
}
const int mxn = 1e5+5;
struct pr{int u,v;};
vector<pr> tree[mxn<<2];
bool ans[mxn];
inline void build(int pos,int lp,int rp,int l,int r,pr range){
if(l<=lp&&rp<=r){
tree[pos].push_back(range);
return;
}
int m = lp+rp >>1;
if(l<=m) build(pos<<1,lp,m,l,r,range);
if(r>m) build(pos<<1|1,m+1,rp,l,r,range);
}
int f[mxn],sz[mxn],dis[mxn];
inline int getf(int x){
if(x==f[x]) return x;
return f[x] = getf(f[x]);
}
inline int getd(int x){
int d = 0;
while(x!=f[x])
d ^= dis[x],x = f[x];//奇数次or偶数次
return d;
}
inline void wor(int pos/*time*/,int l,int r){
vector<pr>opt;
int m = l+r >>1;
bool flag = 0;
int sz1 = tree[pos].size();
for(int i = 0;i < sz1; ++i){
int x = tree[pos][i].u,y = tree[pos][i].v;
int fx = getf(x),fy = getf(y);
if(fx==fy){
if(!(getd(x)^getd(y))){
flag = 1;
break;
}//没有距离
}else{
if(sz[fx]>sz[fy]) swap(fx,fy),swap(x,y);
sz[y] += sz[x];
dis[fx] ^= dis[x]^dis[y]^1;
f[fx] = fy;
opt.push_back((pr){fx,fy});
}
}
if(!flag){
if(l==r) ans[l] = true;
else wor(pos<<1,l,m),wor(pos<<1|1,m+1,r);
}
int sz2 = opt.size();
for(int i = sz2-1; i > 0; --i){
int x = opt[i].u,y = opt[i].v;
sz[y] -= sz[x];
dis[x] = 0;
f[x] = x;
}
}
int n,m,T;
int main(){
rep(i,1,m){
}