# BZOJ 3218/UOJ #77 a + b Problem

VFK出的神题啊。。。

Po姐前面A+B的代码打的吼啊！滑稽

#include<bits/stdc++.h>
using namespace std;
const int M=100005,N=5005,inf=1e9+7;
char ch=getchar(); int x=0,f=1;
while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0'; ch=getchar();}
return x*f;
}
struct E{int y,c,next;}e[M*10]; int len,first[M];
void ins(int x,int y,int c){
e[++len]=(E){y,c,first[x]},first[x]=len;
e[++len]=(E){x,0,first[y]},first[y]=len;
}
int h[M],t,tot; queue<int>q;
bool bfs(){
for(int i=0;i<=tot;i++)h[i]=0;
q.push(0); h[0]=1;
while(!q.empty()){
int x=q.front(); q.pop();
for(int k=first[x];k;k=e[k].next){
int y=e[k].y;
if(!h[y] && e[k].c){h[y]=h[x]+1; q.push(y);}
}
}
return h[t]>0;
}
int dfs(int x,int f){
if(x==t)return f;
int de=0;
for(int k=first[x];k;k=e[k].next){
int y=e[k].y;
if(h[y]==h[x]+1){
int sf=dfs(y,min(f-de,e[k].c));
e[k].c-=sf,e[k^1].c+=sf,de+=sf;
if(de==f)return f;
}
}
if(!de)h[x]=0;
return de;
}
int lc[M],rc[M],rt[M],a[N],L[N],R[N],Q[N*3];
void link(int x,int l,int r,int i)
{
if(!x || L[i]>r || R[i]<l)return;
if(L[i]<=l && r<=R[i])return ins(x,i*2+1,inf);
int mid=(l+r)>>1;
}
void add(int &x,int u,int l,int r,int i){
x=++tot;
if(l==r){
if(u)ins(u,x,inf);
return ins(i*2,x,inf);
}
int mid=(l+r)>>1;
if(lc[x])ins(lc[x],x,inf);
if(rc[x])ins(rc[x],x,inf);
}
int main()
{
for(int i=1;i<=n;i++){
ins(0,i*2,w),ins(i*2,t,b),ins(i*2+1,i*2,p);
ans+=b+w;
Q[++ql]=L[i],Q[++ql]=R[i],Q[++ql]=a[i];
}
sort(Q+1,Q+1+ql);
ql=unique(Q+1,Q+1+ql)-Q-1; tot=n*2+1;
for(int i=1;i<=n;i++){
a[i]=lower_bound(Q+1,Q+1+ql,a[i])-Q;
L[i]=lower_bound(Q+1,Q+1+ql,L[i])-Q;
R[i]=lower_bound(Q+1,Q+1+ql,R[i])-Q;
}