Скоро Codeforces Round 1133 (Div. 1, Div. 2)! Регистрация здесь. ×

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

Автор HishamDroubi, история, 5 лет назад, По-английски

lately I starting studying segment tree in the EDU section

there are some problem to practice that the introducer didnt solve and leave it as exercises

I tried to solve this one but unfortunately the result was (time limit exceeded)

can you help me solving this problem or tell me what is the problem in my solution

this is the problem

274684B-Cryptography

and this is my solution My Solution

Edit: Unfortunately, it seems that I cannot point to the solution and the problem because it is in the member section so I will put them as links

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

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Returning a 2d vector multiple times in a recursive function causes your code to TLE. You can either use 4 integers to represent the 2x2 matrix (which was what I did) or implement iterative segment tree (too lazy to implement it but I guess it should work). Click here to view my accepted code.

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

Just use a 1d vector of size 4x1 and it will get accepted. I was facing the same issue with 2d vector.