# bzoj4059

2种方法

1.线段树+扫描线，将矩形两条边变为一条插入一条删除 nlogn

2.二维线段树 nlog^2n

*不太想写正解没什么意思。。

*把清空操作变成vector记录就能过了我懒得改了

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rint register int
#define rep(i,h,t) for (rint i=h;i<=t;i++)
#define dep(i,t,h) for (rint i=t;i>=h;i--)
#define mid ((h+t)/2)
#define me(x) memset(x,0,sizeof(x))
char ss[1<<24],*A=ss,*B=ss;
char gc()
{
}
{
rint f=1,c; while (c=gc(),c<48||c>57) if (c=='-') f=-1; x=c^48;
while (c=gc(),c>47&&c<58) x=(x<<3)+(x<<1)+(c^48); x*=f;
}
const int N=3e5;
int n,m,pre[N],scc[N],data[N*4],x[N];
map<int,int>pos;
bool v[N*4];
struct re{
int a,b,c,d;
}a[N*4];
bool cmp(re x,re y)
{
return (x.a<y.a||((x.a==y.a)&&x.d>y.d));
}
void updata(int x)
{
if (data[x]>0||(v[x*2]&&v[x*2+1])) v[x]=1; else v[x]=0;
}
void insert(int x,int h,int t,int h1,int t1,int pos)
{
if (h1<=h&&t<=t1)
{
data[x]+=pos;
updata(x); return;
}
if (h1<=mid) insert(x*2,h,mid,h1,t1,pos);
if (t1>mid) insert(x*2+1,mid+1,t,h1,t1,pos);
updata(x);
}
int main()
{
freopen("1.in","r",stdin);
freopen("1.out","w",stdout);
int T;
rep(tt,1,T)
{
pos.clear();
me(pre); me(scc); me(data); me(v);
rep(i,1,n)
{
pre[i]=pos[x[i]]+1;
if (pos[x[i]]) scc[pos[x[i]]]=i-1;
pos[x[i]]=i;
}
rep(i,1,n)
{
if (!pre[i]) pre[i]=1;
if (!scc[i]) scc[i]=n;
}
rep(i,1,n)
{
a[i*4-3].a=pre[i]; a[i*4-3].b=i; a[i*4-3].c=scc[i]; a[i*4-3].d=1;
a[i*4-2].a=i+1; a[i*4-2].b=i; a[i*4-2].c=scc[i]; a[i*4-2].d=-1;
a[i*4-1].a=i; a[i*4-1].b=pre[i]; a[i*4-1].c=i; a[i*4-1].d=1;
a[i*4].a=scc[i]+1; a[i*4].b=pre[i]; a[i*4].c=i; a[i*4].d=-1;
}
int m=n;
n=4*n;
sort(a+1,a+n+1,cmp);
bool t=1;
//  for (int i=1;i<=n;i++)
//   cout<<a[i].a<<" "<<a[i].b<<" "<<a[i].c<<" "<<a[i].d<<endl;
rep(i,1,n)
{
if (a[i].a>m) break;
insert(1,1,m,a[i].b,a[i].c,a[i].d);
if (a[i+1].a!=a[i].a&&!v[1])
{
t=0; printf("boring\n");
break;
}
}
if (t) printf("non-boring\n");
}
return 0;
}

posted @ 2018-07-08 15:15  尹吴潇  阅读(156)  评论(0编辑  收藏  举报