Range Update Query
Sequence A = { a0,a1 ,..., an−1 }に 's really into expands, の2つの operation うプログラムを as せよ.
- update(s,t,x): as,as+1 ,..., at x occupies slew more able.
- find(i): The output of the ai able.
ただし, ai ( i=0,1 ,..., n−1 ) は, 231-1で early されているものとする.
into force
nqquery1query2:queryq
1 lines occupies A the number of elements n , クエリの number q が and えられる. Yobitsugi bootcut q Line occupies i のクエリ queryi が and えられる. queryiは The following のいずれかの forms で and えられる.
stx
または
i
Each クエリの the first digital は, クエリの species of expands, ' 0 ' が update(s,t,x) , ' 1 ' が find(i) table Bamboo Blind.
Output
Each find クエリについて, 1 lines occupies output せよ.
System
- 1≤n≤100000
- 1≤q≤100000
- 0≤s≤t<n
- 0≤i<n
- 0≤x<231−1
into force example 1
3 50 0 1 10 1 2 30 2 2 21 01 1
Output Example 1
13
into force Example 2
1 31 00 0 0 51 0
Output Example 2
21474836475
Interval modification, single point query, Segment Tree +tag tag. Press the pressure constant, continue to hit the list.
1#include <cstdio>2#include <cstdlib>3#include <cstring>4 5 #defineSiz 100000006 7 CharBuf[siz], *bit =buf;8 9InlineintNextint (void) {TenRegisterintRET =0; OneRegisterintNeg =false; A - for(; *bit <'0'; ++bit) - if(*bit = ='-') Neg ^=true; the - for(; *bit >='0'; ++bit) -RET = RET *Ten+ *bit-'0'; - + returnNeg? -Ret:ret; - } + A #defineINF 2147483647 at - intN, M; - - inttag[400005]; - - intFindintTintLintRintp) { in if(~Tag[t]) - returnTag[t]; to intMid = (L + r) >>1; + if(P <=mid) - returnFind (t <<1, L, Mid, p); the Else * returnFind (t <<1|1, Mid +1, R, p); $ }Panax Notoginseng - voidUpdateintTintLintRintXintYintk) { the if(L = = x && r = =y) +TAG[T] =K; A Else { the intMid = (L + r) >>1; + if(~Tag[t]) -Tag[t <<1] = Tag[t <<1|1] = Tag[t], tag[t] =-1; $ if(Y <=mid) $Update (t <<1, L, Mid, X, Y, k); - Else if(X >mid) -Update (t <<1|1, Mid +1, R, X, y, k); the Else { -Update (t <<1, L, Mid, X, Mid, k);WuyiUpdate (t <<1|1, Mid +1, R, Mid +1, y, k); the } - } Wu } - AboutSigned Main (void) { $Fread (BUF,1, Siz, stdin); - -n =nextint (); -m =nextint (); A + for(inti =0; I < (n <<2); ++i) theTag[i] =inf; - $ for(inti =1; I <= m; ++i) { the intc =nextint (); the if(c)//Find (x) theprintf"%d\n", Find (1,1, N, Nextint () +1)); the Else { - intx =nextint (); in inty =nextint (); the intK =nextint (); theUpdate1,1, N, x +1, Y +1, k); About } the } the the //System ("pause"); +}
@Author: Yousiki
AOJ dsl_2_d Range Update Query (Ruq)