1067: [SCOI2007] Rainfall time limit:1 Sec Memory limit:162 MB
submit:2148 solved:554
[Submit] [Status] Description
We often say this: "X year is the most rainfall since y years." It means that the rainfall in x years does not exceed Y years, and the rainfall for any y
Input
Enter only one row that contains a positive integer n, which is the known data. The following n lines are two integers per line, Yi and Ri, for years and rainfall, arranged from small to large by year, i.e. Yi
Output
For each query, output true,false or maybe.
Sample Input6
2002 4920
2003 5901
2004 2832
2005 3890
2007 5609
2008 3024
5
2002 2005
2003 2005
2002 2007
2003 2007
2005Sample Outputfalse
True
False
Maybe
FalseHINT
100% data satisfies: 1<=n<=50000, 1<=m<=10000, -10^9<=yi<=10^9, 1<=ri<=10^9
Source
POJ 2637 Worstweather ever
Puzzle: I really did choose a life of the topic amount ... Tt... I've been struggling for 2 hours ... Good idea-in fact, the core component is a ball interval maximum (you can choose RMQ or line tree, but it is recommended RMQ, because the complexity of the line tree O (logn) can not hurt Ah, do not forget the time limit is 1s), the next is a variety of pit Dad wa--reason is very simple and not simple- Although the problem of true is only one of the obvious, but maybe has n many cases!!! Oh, hell!!! To go crazy ... Next quote Hzwer god Ben Words, I change to change to also speak not very clear, but the general meaning is this (hzwer of the Solving portal):
There are a lot of things to consider. For example, from the year X to the year Y
If y<x, I don't know if this is the case, it should be false.
True if the condition needs to be met
X and Y values both known and Y values <x values and x+1 to Y-1 are known and are less than Y values
Maybe meet
1.x value Y value is unknown
2. Known x value unknown y value and x+1 to Y-1 are known and are less than Y values
3. Known y value unknown x value and x+1 to Y-1 are known and are less than X value
4.x is the largest year in a year, y>x
5.Y is the smallest year in a year, x<y
6.x,y are known and y<x and x+1 to Y-1 are unknown and are less than X-values
All the others are false.
Probably like this ...
The problem is that the AC is God
For a couple of hours.
1 varHansbug's Moe Code2C,b:Array[0..100010] ofLongint;3X, Y:Array[0..100010] ofLongint;4F:Array[0..100010,0.. -] ofLongint;5 I,j,k,n,m,x0,y0:longint;6 functionMax (a,b:longint): Longint;7 begin8 ifA>b ThenExit (a)Elseexit (b);9 End;Ten functioncal (L,r:longint): Longint; One var A J:longint; - begin - ifR<l ThenExit (-1); theJ:=trunc (LN (r-l+1)/LN (2)); -Exit (Max (f[l][j],f[r-(1SHL j) +1][j])); - End; - procedurebuilt; + var - I,j:longint; + begin A forj:=1 toTrunc (ln (n)/ln (2)) Do at fori:=1 toN-1SHL j+1 Do -F[i][j]:=max (f[i][j-1],f[i+1SHL (J-1)][j-1]); - End; - functionFind (X:longint): Longint; - var - L,r,mid:longint; in begin -l:=1; r:=N; to whileL<r Do + begin -mid:= (l+r) shr1; the ifC[mid]=x Thenexit (mid); * ifC[mid]<x ThenL:=mid+1 Elser:=mid-1; $ End;Panax Notoginseng exit (l); - End; the begin + read (n); A fori:=1 toN Do the read (c[i],b[i]); + fori:=1 toN Do -f[i][0]:=B[i]; $ built; $ read (m); - fori:=1 toM Do - begin the read (x0,y0); - ifX0>y0 ThenWuyi begin theWriteln ('false'); - continue; Wu End; -j:=find (x0); Aboutk:=find (y0); $ if(c[j]=x0) and(C[K]=Y0) Then - if(Y0-X0=K-J) Then - if(B[j]>=b[k]) Then - ifCal (j+1, K-1) <b[k] Then A begin +Writeln ('true'); the continue; - End; $ if(c[j]<>x0) and(C[K]<>Y0) Then the begin theWriteln ('maybe'); the continue; the End; - if(c[j]<>x0)or(C[K]<>Y0) Then in begin the while(c[j]>x0) and(j<>0) DoDec (j); the while(C[K]<Y0) and(k<=n) DoInc (k); About ifC[j]<>x0 ThenY0:=kElsey0:=J; theX0:=cal (j+1, K-1); the ifX0<B[Y0] ThenWriteln ('maybe')ElseWriteln ('false'); the continue; + End; - if(k-j<>y0-x0) Then the if(B[j]>=b[k]) ThenBayi begin theX0:=cal (j+1, K-1); the ifX0<B[K] ThenWriteln ('maybe')ElseWriteln ('false'); - continue; - End; theWriteln ('false'); the End; the End.
1067: [SCOI2007] Rainfall