F.A.Qs Home ProblemSet Status Ranklist Contest LoginRegister
Notice:1:注册本OJ方式请见https://www.lydsy.com/JudgeOnline/wttl/thread.php?tid=5671 2:请不要在讨论区中发空白主题帖。
大视野在线测评-欢迎您
[ New Thread ]
Problem 1067 >> 1067 Runtime_Error !?
kjy @ 2018-08-08 12:12:38
[ Quote ] [ Edit ] [ Delete ] 1#
双手奉上程序,求大佬帮助。
#include<iostream>
#include<cstdio>
#define_imax(a,b)_((a>b)?(a):(b))
#define_imin(a,b)_((a<b)?(a):(b))
#define_is(ch)_(ch>='0'&&ch<='9')
#define_ok_continue

using_namespace_std;

inline_void_read(int_&x)
{
_______x=0;char_ch=getchar();bool_f=0;
_______for_(;!is(ch);ch=getchar())_f|=(ch=='-');
_______for_(;_is(ch);ch=getchar())_x=(x<<3)+(x<<1)+(ch^48);
_______x=f?-x:x;
}
const_int_maxn=60005;
int_n,kd,G;
struct_tree{int_s;bool_k;}_______t[maxn<<2];
struct_data{int_a,b,c;}_______d[maxn];
struct_tru{int_x,y;}kp[2][2];
int_Find(int_val)
{
_______int_L=0,R=n+1;
_______while_(L+1<R)
_______{
______________int_Mid=(L+R)>>1;
______________if_(d[Mid].a<=val)_______L=Mid;
_____________________else_____________________R=Mid;
_______}
_______return_L;
}
inline_void_up(int_ro)
{
_______t[ro].s=imax(t[ro<<1].s,t[ro<<1|1].s);
_______t[ro].k=t[ro<<1].k|t[ro<<1].k;
}
void_build(int_ro,int_L,int_R)
{
_______if_(L==R)
_______{
______________t[ro].s=d[ro].b;
______________t[ro].k=d[ro].c;
______________return;
_______}
_______int_Mid=(L+R)>>1;
_______build(ro<<1,L,Mid);
_______build(ro<<1|1,Mid+1,R);
_______up(ro);
}
int_query(int_ro,int_L,int_R,int_li,int_ri)
{
_______if_(L>ri||R<li)_______return_-1e9;
_______if_(L>=li&&R<=ri)
_______{
______________kd|=t[ro].k;
______________return_t[ro].s;
_______}
_______int_Mid=(L+R)>>1;
_______int_x=query(ro<<1,L,Mid,li,ri);
_______int_y=query(ro<<1|1,Mid+1,R,li,ri);
_______return_imax(x,y);
}
int_main()
{
//_______freopen(".in","r",stdin);
//_______freopen(".out","w",stdout);
_______kp[1][0]=(tru){1,-1};kp[0][1]=(tru){0,-1};kp[1][1]=(tru){1,-1};
_______read(n);
_______for_(int_i=1;i<=n;i++)
_______{
______________read(d[i].a);read(d[i].b);
______________d[i].c=(d[i].a-d[i-1].a>1)&&(i!=1);
_______}
_______build(1,1,n);
_______read(G);
_______while_(G--)
_______{
______________int_x,y;
______________read(y);read(x);
______________if_(x>=y)_______{printf("false\n");ok;}
______________if_(x<d[1].a||y>d[n].a){printf("maybe\n");ok;}
______________int_wx=Find(x),wy=Find(y);
______________bool_tx=x==d[wx].a,ty=y==d[wy].a;
______________if_(!(tx||ty))_______{printf("maybe\n");ok;}
______________kd=(d[wx+1].a-d[wx].a)|(d[wy].a-d[wy-1].a);
______________int_Max=query(1,1,n,wx+kp[tx][ty].x,wy+kp[tx][ty].y);
______________if_(tx&&ty&&d[wy].b>d[wx].b&&Max<d[wx].b)_______{printf("%s\n",kd?"maybe":"true");ok;}
______________printf("%s\n",(tx&&!(ty)&&Max<d[tx].b)||(!(tx)&&ty&&Max<d[ty].b)?"maybe":"false");
_______}
_______return_0;
}
luodanyu @ 2018-08-08 13:00:56
[ Quote ] [ Edit ] [ Delete ] 2#
道理我都懂,但你怎么可以把缩进改成下划线啊
[Top] [Previous Page] [Next Page]

HOME Back