By Sadat999, 4 weeks ago, ,

Problem from CF EDU.

Problem Description

I am getting RTE for literally all possible submissions I can make. Here is my poor RTE'd submission.

Local testing showed that the second submission is working correctly for the value of n up to 10000, but for higher values, it is not.

Can anyone please explain the reason behind this weird behaviour and the way to fix it?

• -6

 » 4 weeks ago, # |   0 Check the following update to your data structure solution.Accepted Update
•  » » 4 weeks ago, # ^ |   0 Can you figure out what the potential bug in my submission is?
•  » » » 4 weeks ago, # ^ |   0 Yes. Your submission was accepted after changing line 39 if (start < (int)res.size()){ to if (start < a.size()){ 
•  » » » » 4 weeks ago, # ^ |   0 Huge Thanks!!!
•  » » » » » 4 weeks ago, # ^ |   0 With pleasure. Lines 95-132 in the following code contain the test generator that I used to figure out the bug in your submission.Test Generator
•  » » » » » » 4 weeks ago, # ^ |   0 Great tool, can you provide me with a reference on how to use this generator?
•  » » » » » » » 4 weeks ago, # ^ | ← Rev. 2 →   0 Check lines 115-117 that contain a simple random integer number generator uniformly distributed in the range [min,max]. The lambda expression is used just like any inline C++ function to generate a random integer value in the required range. The Boolean constant submit is used to switch between the test mode and the code submission mode. If this value is false, the test-case is generated using the random number generator. Otherwise, the test-case is read from the standard input stream.