I_Love_AnhThu's blog

By I_Love_AnhThu, history, 4 hours ago, In English

Given a constant $$$s$$$, an array of $$$n$$$ non-negative integers and you have to process $$$q$$$ queries of following types :

  1. $$$l \ r \ b$$$ : for each $$$i$$$ in range $$$[l, r]$$$, if $$$a[i] < b$$$ let $$$a[i] = s - a[i]$$$
  2. $$$l \ r \ b$$$ : for each $$$i$$$ in range $$$[l, r]$$$, if $$$a[i] > b$$$ let $$$a[i] = s - a[i]$$$
  3. $$$i$$$ : return the current value of $$$a[i]$$$

$$$1 \leq n, q \leq 5.10^5$$$ $$$1 \leq s, b \leq 10^7$$$

Time limit : 2.5s Memory limit : 512 mb

I'm trying to solve the easier problem when all the updates appear before the queries, but I still can't; I don't have any approach for this problem yet, can anyone give me some hints or something ? Sorry for bad English :( Thanks :)

  • Vote: I like it
  • +5
  • Vote: I do not like it

»
4 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by I_Love_AnhThu (previous revision, new revision, compare).

»
4 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by I_Love_AnhThu (previous revision, new revision, compare).

»
4 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Problem source?

»
4 hours ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

do u have any idea about Segment Tree and Lazy Propagation??

»
4 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Segment tree with lazy propagation?

»
44 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

Reach specialist first bruh