TIME LIMIT EXCEEDED

I HAVE USED THE BASIC APPROACH OF CONSTRUCTION SEGMENT TREE WHERE EACH RANGE INDEX HAVE MULTIPLICATION OF ALL AND I AM GIVING THE OUTPUT OF THE ASKED QUERY

MY CODE=>https://ide.codingblocks.com/s/337430

I AM GETTING TLE FOR 2 CASES

@gagangoyal674
Your code is absolutely fine. The problem lies in the returning and passing of matrix parameters. Because of the constant initialization and reinitialization, the program slows down significantly. When doing the query, you should send a matrix by reference and whenever you face a situation of complete overlap, you should multiply it then and there, so that the changes are made in the final answer and you do not have to return and pass matrices by value any more.

This is my code for the problem:

Go through it once and revert in case you face any difficulty.
If my answer was able to resolve your query, please mark the doubt as resolved.

I have tried passing it by reference but it doe’s no good to my test case

MY CODE => https://ide.codingblocks.com/s/337743 and also what is the best to use struct or class specially in this case

@gagangoyal674
Will go through the code and revert back. Both of them work just fine.

Did you go through my code ??