#哪都错了
by 老王B @ 2017-12-03 20:17:40
抱歉,我傻了,请忽略此条
by cjy_chenjiayi @ 2017-12-03 20:18:43
```cpp
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
typedef struct Node
{
Node *l,*r;
int maxm,st,ed;
Node(int a,int b,int d,Node *e,Node *f)
{
st=a,ed=b,maxm=d;
l=e,r=f;
}
}*pnode;
pnode root;
int y[100100],a[100100];
pnode set(int st,int ed)
{
if(st==ed)
{
pnode r=new Node(st,st,a[st],0,0);
return r;
}
int mid=(st+ed)/2;
pnode r=new Node(st,ed,0,set(st,mid),set(mid+1,ed));
r->maxm=max(r->l->maxm,r->r->maxm);
return r;
}
int find(int st,int ed,pnode r)
{
if(st>ed)return -2147483647;
if(st<=r->st&&ed>=r->ed)
return r->maxm;
int maxm=-2147483647;
if(st<=r->l->ed)
maxm=max(maxm,find(st,ed,r->l));
if(ed>=r->r->st)
maxm=max(maxm,find(st,ed,r->r));
return maxm;
}
int n;
int change(int x)
{
int st=1,ed=n;
while(st<ed)
{
int mid=(st+ed)/2;
if(y[mid]<x)
st=mid+1;
else if(y[mid]==x)return mid;
else ed=mid;
}
return st;
}
int main()
{
std::ios::sync_with_stdio(false);
cin>>n;
for(int i=1;i<=n;i++)
cin>>y[i]>>a[i];
root=set(1,n);
int m;
cin>>m;
while(m--)
{
int X,Y;
cin>>Y>>X;
int u=change(Y),v=change(X);
if(y[u]==Y&&y[v]==X)
{
if(a[u]<a[v]){cout<<"false"<<endl;continue;}
else if(v==u+1){
if(X==Y+1){cout<<"true"<<endl;continue;}
else {cout<<"maybe"<<endl;continue;}
}
else
{
int t=find(u+1,v-1,root);
if(t>=a[v]){cout<<"false"<<endl;continue;}
if(X-Y==v-u)cout<<"true"<<endl;
else cout<<"maybe"<<endl;
}
}
else if(y[v]==X&&y[u]!=Y)
{
if(u==v){cout<<"maybe"<<endl;continue;}
int t=find(u,v-1,root);
if(t>a[v])cout<<"false"<<endl;
else cout<<"maybe"<<endl;
}
else if(y[u]!=Y&&y[v]==X)
{
if(v==u+1){cout<<"maybe"<<endl;continue;}
int t=find(u+1,v-1,root);
if(t>=a[u])cout<<"false"<<endl;
else cout<<"maybe"<<endl;
}
else
cout<<"maybe"<<endl;
}
return 0;
}
```
/\*
6
2002 4920
2003 5901
2004 2832
2005 3890
2007 5609
2008 3024
5
2002 2005
2003 2005
2002 2007
2003 2007
2005 2008
\*/
by cjy_chenjiayi @ 2017-12-03 20:53:50
再次求助,真的不知道自己哪里错了(有没有小一点的错误数据,谢谢)
by cjy_chenjiayi @ 2017-12-03 20:54:50