Блог пользователя vikas11111

Автор vikas11111, история, 13 месяцев назад, По-английски

I wants to do this question with segment tree
i know i can change element in logn time but how i can check there at least on segment available or not according to the que

que link link

plz help

  • Проголосовать: нравится
  • -6
  • Проголосовать: не нравится

»
13 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In the contest, I tried implementing the Segment tree and thought the prefix array won't pass the time constraints, but I was wrong, here is my segment tree AC solution although it can be further optimized.

https://mirror.codeforces.com/contest/1843/submission/210506220

Also I didn't quite get wym by " check there at least on segment available " ??

»
13 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

you don't need segment trees for this... its just a basic binary search

»
13 месяцев назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

Why learning segment trees when you haven't even solved 1300-Rated problems ?

  • »
    »
    13 месяцев назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

    Yeah, In last maybe 20 rounds i dont see a problem(with rating <= 2000), which have solution like "segment tree" or simething more harder. But learning it when you are 1000...

»
13 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

If you're curious, this is a working solution with binary search and prefix sums — no segtree needed, and takes only ~60ms and 1.5MB: 210537397

»
13 месяцев назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Why do you learn Segment Tree? Go learn Binary Search.

In fact Binary Search was the expected solution, stop overcomplicating your solutions using hard algorirthms.

»
13 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

If you are interested in the range update method of solving the problem but you need an easy way to do this, I recommend the square root algorithm. It's more suited for beginners, and it is what I used in the contest.