plz somebody explain me code of fibq with comments in c++.

plz somebody explain the c++ code of fibq with comments i am not able to understand codechef editorial

For Implementation :

https://www.codechef.com/viewsolution/9898602

  1. Identity_Matrix + FiboMatrix(array_element) in the leaf nodes of the segment tree ( each node represents a 2X2 matrix)

  2. For the result query, Multiply all the matrices in the range [l, r] and answer is resultMatrix[0][1]

  3. The update query follows from the step 1.

(By FiboMatrix(array_element) , I mean { {1,1},{1,0} } ^ array_element )

The code is self-explainatory :slight_smile:

Hope it helps.

2 Likes

I need to report a problem I am facing due to which I can’t see the problems and ranks and everything on contest page. However, I don’t have enough Karma Points. Somebody please help.

3 Likes

This is the same problem I face with most of the editorials. There are some guys who write really nice editorials. But most of the time, the person who is writing editorial thinks that the person have some knowledge about the topic and just skips it. Or just writes in a way which is difficult to understand. Therefore sometimes it takes even weeks to solve the problem.

Another thing I will like to request is that “Can the Editorialist’s solution be written in Python?” because
understanding Python is really easy and makes it helpful to understand the solution. Also c/c++ is used because they are quite fast as compared to other languages, but we don’t need speed in editorials.

2 Likes

They don’t have a set rule for using C++ in editorials. It’s upto the ease of editorialists.

Yes, even then I have never seen an editorial in Python. I think Python should be given preference to C/C++.

Why should it be language specific? The editorial should just explain the algorithm. Try to be as readable as possible. Like it is the Cormen book. Instead upload codes in various languages for reference.

1 Like