Cristiano07's blog

By Cristiano07, history, 2 years ago, In English

Hi, I was doing this problem https://codeforces.com/contest/1620/problem/E and have some questions about the more general version of this problem: Given an array of n elements, we are given q numebr of queries: l r x y — change all occurances of number 'x' to 'y' in the [l,r] segment of the array. Lastly, we want to print all elements of the array after these queries. Constraints: n,q <= 200000. TL 1 second, ML 256 MB. I know there is a solution using DSU-on-tree, but is there a segment trees/lazy propagation approach to this problem that is efficient enough to fit in the time limit? This was my first intuitive approach (since the problem involves range updates) but I couldn't seem to find a way with it.

Full text and comments »

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