Transmission Door
The problem is drunk.
The estimate is a special, not a data structure.
Examine the use of if and else
Mainly consider the classification of several cases to see the code bar
Yes, I'm writing a line tree, because I'm lazy, and I'm tired of St.
#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#define N 50000+5#define M 200000+5using namespace STD;intYear[n],a[n],n;inline intRead () {intx =0, F =1;Charch = getchar (); while(Ch <' 0 '|| CH >' 9 ') {if(ch = ='-') F =-1; ch = getchar (); } while(Ch >=' 0 '&& CH <=' 9 ') {x = x *Ten+ CH-' 0 '; ch = getchar (); }returnx * F;}structdata{intL,R,MN;} TR[M];voidBuildintKintLintR) {tr[k].l=l,tr[k].r=r;if(L==R) {Tr[k].mn=a[l];return;}intMid= (l+r) >>1; Build (k<<1, L,mid); Build (k<<1|1, mid+1, R); Tr[k].mn=max (tr[k<<1].mn,tr[k<<1|1].MN);}intAskintKintSintT) {if(s>t)return-1;intL=TR[K].L,R=TR[K].R;if(S==l && t==r)returntr[k].mn;intMid= (l+r) >>1;if(T<=mid)returnAsk (k<<1, s,t);if(S>mid)returnAsk (k<<1|1, s,t);returnMax (Ask (k<<1, S,mid), Ask (k<<1|1, mid+1, t));}intMain () {//Freopen ("Rains.in", "R", stdin);//Freopen ("Rains.out", "w", stdout); Cin>>n; for(intI=1; i<=n;++i) Year[i]=read (), A[i]=read (); Build1,1, n);/*for (int i=1;i<=n;++i) printf ("y[%d]=%d a[%d]=%d\n", i,year[i],i,a[i]); * / intQCin>>q; while(q--) {intA=read (), B=read ();intL=lower_bound (year+1, year+n+1, A)-year;intR=lower_bound (year+1, year+n+1, B)-year;if(Year[l]==a && year[r]==b) {if(A[l]<a[r] | | | Ask (1, L +1, R-1) >= A[r])puts("false");Else if(b-a = = r-l)puts("true");Else puts("Maybe"); }Else if(Year[l]!=a && year[r]!=b)puts("Maybe");Else if(Year[r]! = B) {if(Ask (1, L +1, R-1) >= A[l])puts("false");Else puts("Maybe"); }Else{if(Ask (1, L, R1) >= A[r])puts("false");Else puts("Maybe"); } }}
Bzoj 1067 Rainfall segment tree