Sadat999's blog

By Sadat999, 4 weeks ago, In English,

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?

 
 
 
 
  • Vote: I like it
  • -6
  • Vote: I do not like it

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Check the following update to your data structure solution.

Accepted Update

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Can you figure out what the potential bug in my submission is?

    • »
      »
      »
      4 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Yes. Your submission was accepted after changing line 39

      if (start < (int)res.size()){
      

      to

      if (start < a.size()){
      
      • »
        »
        »
        »
        4 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Huge Thanks!!!

        • »
          »
          »
          »
          »
          4 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          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, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Great tool, can you provide me with a reference on how to use this generator?

            • »
              »
              »
              »
              »
              »
              »
              4 weeks ago, # ^ |
              Rev. 2   Vote: I like it 0 Vote: I do not like it

              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.