Hisham_hates_graphs's blog

By Hisham_hates_graphs, history, 3 years ago, In English

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

| Write comment?
»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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.