# 洛谷4269 [usaco18feb]snow boots g

## 奶牛套路题

Posted by yjjr's blog on January 27, 2019

# code

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=Last[x];i;i=e[i].Next)
using namespace std;
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
const int maxn=1e5+6;
int n,b,mx=1,Last[maxn],Next[maxn];
bool ans[maxn];
struct node1{int dep,id;}f[maxn];
struct node2{int dep,dis,id;}s[maxn];
inline bool cmp1(node1 a,node1 b){return a.dep<b.dep;}
inline bool cmp2(node2 a,node2 b){return a.dep<b.dep;}
void Del(int x){Last[Next[x]]=Last[x];Next[Last[x]]=Next[x];}
int main(){
sort(f+1,f+1+n,cmp1);
sort(s+1,s+1+b,cmp2);
rep(i,1,n)Last[i]=i-1,Next[i]=i+1;
int j=n;
dep(i,b,1){
while(j>=1&&f[j].dep>s[i].dep){
Del(f[j].id);
mx=max(mx,Next[f[j].id]-Last[f[j].id]);
j--;
}
if(s[i].dis>=mx)ans[s[i].id]=1;
}
rep(i,1,b)printf("%d\n",ans[i]);
return 0;
}