Tag: Line statistic string UTC = ... src comparison com
The language of the people is really good ...
different labels and heights = each different label + individual height ...
The first question is relatively simple, consider inserting from large to small, in the same case, by key values from small to large insert
In this way, the key elements must affect the key small elements, do not leak statistics
When inserting the $i$ element, it is advisable to set a number larger than it to $s$, limited to $lim$, and it is the same and has been inserted in a number of $j$ species
Then there are $min (S, Lim) + j$ type of insertion scheme
The second question is relatively simple.
Consider $dp$, so that $f (i, j) $ is represented in the same number, inserted into the $i$, and $i$ inserted in section $j$
Since the order of insertions does not affect the answer, we can limit the key values to be small and must be inserted behind the key values
Transfer with prefix and transfer on line
We remove $o (p) $ of potential energy needs $o (P^2) $ time
And the potential energy of the sequence is only $o (n) $, so our complexity will not exceed $o (n^2) $
#include <vector>#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>namespaceRemoon {#defineRe Register#defineDe double#defineLe long double#defineRI Register int#definell Long Long#defineSH short#definePII Pair<int, int>#defineMP Make_pair#definePB Push_back#defineTPR Template <typename ra>#defineRep (IU, St, ed) for (ri iu = st; IU <= ed; iu + +)#defineDrep (IU, ed, St) for (ri iu = ed; iu >= St; IU--)externInlineCharGC () {Static Charrr[23456], *s = RR +23333, *t = RR +23333; if(S = = T) fread (RR,1,23333, stdin), S =RR; return*s + +; } InlineintRead () {intp =0, W =1;Charc =GC (); while(C >'9'|| C <'0') {if(c = ='-') W =-1; c =GC ();} while(c >='0'&& C <='9') p = p *Ten+ C-'0', C =GC (); returnP *W; } intwr[ -], rw; #definePC (IW) Putchar (IW)TPR InlinevoidWrite (Ra o,Charc ='\ n') { if(!o) PC ('0'); if(O <0) o =-O, PC ('-'); while(o) wr[++ rw] = o%Ten, O/=Ten; while(rw) PC (WR[RW--] +'0'); PC (c); } TPR InlinevoidCmin (RA &a, RA b) {if(A > B) a =b;} TPR InlinevoidCmax (RA &a, RA b) {if(A < b) A =b;} TPR InlineBOOLCkmin (RA &a, RA b) {return(A > B)? A = B,1:0; } TPR InlineBOOLCkmax (RA &a, RA b) {return(A < b)? A = B,1:0; }}using namespacestd;using namespaceRemoon;#defineSID 1050#defineMoD 2011inlinevoidInc (int&a,intb) {A + = B;if(a >= mod) A-=MoD;} InlineintMulintAintb) {return1LL * A * b%MoD;}intN;structMountain {inth, K; FriendBOOL operator<(Mountain A, mountain b) {returnA.h > B.h && (a.h = = B.h && A.K <B.K); }} Mt[sid];intf[1050][1050];inlinevoidSolve () {intAns =1; for(RI i =1, j =1; I <= N; i = j +1) {J= i; while(Mt[j].h = = Mt[j +1].h) J + +; Rep (IP, I, j) cmin (MT[IP].K, i); Rep (IP,1, MT[I].K) F[i][ip] =1; Rep (IP, I, j) {if(IP < J) Rep (JP,1, Mt[ip +1].K) Inc (F[IP][JP], F[IP][JP-1]); ElseRep (JP,1, MT[IP].K) Inc (F[IP][JP], F[IP][JP-1]); if(IP < J) Rep (JP,1, Mt[ip +1].K) F[ip +1][JP] =F[IP][JP]; } ans=mul (ans, f[j][mt[j].k]); } write (ans);}intMain () {n=read (); Rep (I,1, n) mt[i].h = Read (), MT[I].K =read (); Sort (Mt+1, MT + N +1); intAns =1, num, pre; Rep (I,1, N) { if(Mt[i].h! = mt[i-1].h) Pre = i, num =0; ElseNum + +; Ans= Mul (ans, min (pre, MT[I].K) +num); } write (ans,' '); Solve (); return 0;}
luoguP3255 [JLOI2013] terrain generation dynamic planning