# luogu_P3674 小清新人渣的本愿

## Code

#include<bits/stdc++.h>
#define ll long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
{
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<<3)+(x<<1)+ch-'0';ch=getchar();}
return x*f;
}
#define MN 100005
#define N MN
int n,m,a[MN],T;
bool Ans[MN];
std::bitset<N> now,fnow;
struct ques{
int l,r,opt,x,id,pl;
bool operator <(const ques&o)const{return (pl^o.pl)?(pl<o.pl):(r<o.r);}
}q[MN];
int num[MN];
int main()
{
//freopen("testdata.in","r",stdin);
//freopen("testdata.out","w",stdout);
register int i;T=ceil(sqrt((double)n));
now.reset();fnow.reset();
for(i=1;i<=m;++i)
{
}
std::sort(q+1,q+m+1);
register int l=1,r=0,j;
for(i=1;i<=m;++i)
{
//printf("l=%d r=%d\n",q[i].l,q[i].r);
for(;r<q[i].r;++r) if(!num[a[r+1]]++) now[a[r+1]]=1,fnow[N-a[r+1]]=1;
for(;l>q[i].l;--l) if(!num[a[l-1]]++) now[a[l-1]]=1,fnow[N-a[l-1]]=1;
for(;r>q[i].r;--r) if(!(--num[a[r]])) now[a[r]]=0,fnow[N-a[r]]=0;
for(;l<q[i].l;++l) if(!(--num[a[l]])) now[a[l]]=0,fnow[N-a[l]]=0;
//std::cout<<now<<std::endl<<fnow<<std::endl;
if(q[i].opt==1) Ans[q[i].id]=(now&(now<<q[i].x)).any();
else if(q[i].opt==2) Ans[q[i].id]=((now<<(N-q[i].x))&fnow).any();
else
{
for(j=1;j*j<=q[i].x;j++)
if(q[i].x%j==0) if(now[j]&&now[q[i].x/j]){Ans[q[i].id]=1;break;}
}
}
for(i=1;i<=m;++i) puts(Ans[i]?"hana":"bi");
return 0;
}


Blog来自PaperCloud，未经允许，请勿转载，TKS！

posted @ 2018-12-25 15:07  PaperCloud  阅读(183)  评论(0编辑  收藏  举报