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

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

I am currently stuck on this problem: https://codeforces.net/contest/296/problem/C Any help would be appreciated. PS: I couldn't understand the editorial

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

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

Hint: If you know how to do queries of incrementing a range where size of array is n(<=100000) and no. of queries q (<=100000) in O(n+q) then u can solve this problem by applying the technique twice. If you dont know the above technique: https://www.youtube.com/watch?v=4AFWuZIbJ9g&ab_channel=HimanshuSingal

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

So the idea to do this problem is you can merge multiple queries of the same type into one query. For example, the query 1 5 3 repeat 5 times is equal to 1 5 15. Then you can just using range queries technique to calculate the number of times each query is used, and then another time to execute the queries to the array. The time complexity is O(n+q) or O(n log n + q log q) depend on the range queries algorithm you used (segment tree, BIT, difference array, or stuff like that)