BZOJ[4592][Shoi2015]脑洞治疗仪 分块

2019-10-16| 发布者: admin| 查看: |

传送门ber~

太长时间没写分块了。。。写一写。。
码力++
都要NOI了还在刷水....



代码如下:

#include algorithm 
#include ctype.h 
#include cstdio 
#include cmath 
#define N 200050
using namespace std;
inline int read{
 int x=0,f=1;char c;
 do c=getchar,f=c=='-'?-1:f; while);
 do x=++c-'0',c=getchar; while);
 return x*f;
int n,m,block_size,sum,ans,l,r,t;
int a[N],block[N],siz[N],cnt[N],ml[N],mr[N],bl[N],br[N],b[N],mx[N];
inline void pushdown{
 if{
 for
 a[i]=0;
 if{
 for
 a[i]=1;
 b[k]=0;
inline void recount{
 cnt[k]=0;
 int p=0;
 mx[k]=0;
 for{
 if p++;
 else p=0;
 mx[k]=max;
 cnt[k]=cnt[k]+a[i];
 ml[k]=siz[k];
 for
 if{
 ml[k]=i-bl[k];
 break;
 mr[k]=siz[k];
 for
 if{
 mr[k]=br[k]-i;
 break;
inline void Debug{
 for{
 printf;
int main{
 n=read;m=read;
 block_size=sqrt;
 for{
 a[i]=1;
 block[i]=/block_size+1;
 cnt[block[i]]=;
 if bl[block[i]]=i;
 br[block[i]]=i;
 for{
 t=read;
 if{
 l=read;r=read;
 if{
 pushdown;pushdown;
 for
 a[j]=0;
 recount;recount;
 else{
 for{
 b[j]=1;
 mx[j]=ml[j]=mr[j]=siz[j];
 cnt[j]=0;
 pushdown;pushdown;
 for
 a[j]=0;
 for
 a[j]=0;
 recount;recount;
 else if{
 l=read;r=read;
 sum=0;
 if{
 pushdown;pushdown;
 for
 if sum++,a[j]=0;
 recount;recount;
 else{
 for{
 sum=sum+cnt[j];
 b[j]=1;
 mx[j]=ml[j]=mr[j]=siz[j];
 cnt[j]=0;
 pushdown;pushdown;
 for
 if sum++,a[j]=0;
 for
 if sum++,a[j]=0;
 recount;recount;
 l=read;r=read;
 if{
 pushdown;pushdown;
 for
 if a[j]=1,sum--;
 recount;recount;
 else{
 pushdown;
 for
 if a[j]=1,sum--;
 recount;
 for{
 if{
 pushdown;
 for
 if a[l]=1,sum--;
 recount;
 break;
 else{
 sum=sum-;
 b[j]=2;
 mx[j]=ml[j]=mr[j]=0;
 cnt[j]=siz[j];
 pushdown;
 for
 if a[j]=1,sum--;
 recount;
 else{
 l=read;r=read;
 ans=sum=0;
 if{
 pushdown;pushdown;
 for{
 if sum++;
 else sum=0;
 ans=max;
 printf;
 else{
 pushdown;
 for{
 if sum++;
 else sum=0;
 ans=max;
 for{
 sum=sum+ml[j];ans=max;
 ans=max;
 if continue;
 else sum=mr[j],ans=max;
 pushdown;
 for{
 if sum++;
 else sum=0;
 ans=max;
 printf;
 return 0;