rt
代码:
#include <bits/stdc++.h>
#define int long long
namespace IO{
template<typename T> inline void read(T &in){
in=0;int fh=1;char ch=getchar();
while(!isdigit(ch)){
if(ch=='-') fh=-1;
ch=getchar();
}
while(isdigit(ch)) in=(in<<1)+(in<<3)+(ch^48),ch=getchar();
in*=fh;
}
template<typename T> inline void write(T out){
static char op[25];int top=0;
if(out<0) putchar('-'),out=-out;
do{op[++top]=out%10+48,out/=10;} while(out);
while(top) putchar(op[top--]);
putchar('\n');
}
template<typename T,typename... Ts> inline void read(T &in,Ts&... ins){read(in),read(ins...);}
template<typename T,typename... Ts> inline void write(T out,Ts... outs){write(out),write(outs...);}
}
using namespace std;
using namespace IO;
const int N=5e4+5;
int n,q,x,y,a[N],b[N],st[N][(int)(log2(N))+5];
map<int,int> mp;
inline int mi(int x) {return 1<<x;}
inline int gtmx(int l,int r) {
int k=log2(r-l+1);
return max(st[l][k],st[r-mi(k)+1][k]);
}
signed main() {
read(n);
for(int i=1;i<=n;i++)
read(a[i]),mp[a[i]]=i,read(b[i]),st[i][0]=x;
for(int i=1;mi(i)<=n;i++)
for(int j=1;j+mi(i)-1<=n;j++)
st[j][i]=max(st[j][i-1],st[j-(mi(i)-1)][i-1]);
read(q);
while(q--) {
read(x,y);
if(mp.find(y)==mp.end()) {
if(mp.find(x)==mp.end()) puts("maybe");
else if(gtmx(mp[x]+1,lower_bound(a+1,a+1+n,y)-a)<b[mp[x]]) puts("maybe");
else puts("false");
}
else if(mp.find(x)!=mp.end()) {
if(b[mp[x]]<b[mp[y]]) puts("false");
else if(gtmx(mp[x]+1,mp[y]-1)>=b[mp[y]]) puts("false");
else if(y-x==mp[y]-mp[x]) puts("true");
else puts("maybe");
}
else {
if(gtmx(lower_bound(a+1,a+1+n,x)-a+1,mp[y]-1)>=b[mp[y]]) puts("false");
else puts("maybe");
}
}
return 0;
}