light_yagami52's blog

By light_yagami52, history, 6 weeks ago, In English

In my editor this python code works fine. But I'm getting Runtime error, exit code 1. Can anyone help me? Click to see My submitted code

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

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

It happens often , in our IDE the code works fine but , Codeforces compliler shows error... try looking for segmentation faults (out of bonds array faults) Rewrite the code , it will help you .. You wont make the bug again :)

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

In my editor this python code works fine.

Does it work fine in your editor when processing exactly the same input data that fails on codeforces?

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

    Every visible test case i tried and it worked fine.I ran some of my test case too.that's also working fine.But CF do not show all the case. So, I'm not sure what is causing this Runtime error, exit code 1. In my code I'm not finding any reason for Runtime error

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

      Being able to debug your code is a useful skill during contests. Sometimes it pays off to generate a large number of randomized testcases and feed them to your code. That's a reasonably fast way to reproduce a lot of the possible runtime errors and TLEs. Do you need some help with that?

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

        Yeah, i need that help.

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

          Here's a quckly hacked testcase generator Ruby script:

          Testcase generator script

          And here's a testcase, which breaks your code:

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

            thanks for your help

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

            Thanks,Got AC. I have a question to ask.I'm bad at corner case handling and making my own test case.Sometimes i write a really complex code. What should i do for that? any suggestion is appreciated .

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

Auto comment: topic has been updated by light_yagami52 (previous revision, new revision, compare).

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

Try this input (as I wrestle with formatting...):

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

    Thanks a lot. I watched your code . Can you please share the details what the dbp function exactly doing ? (https://imgur.com/8NosVjJ)

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

      dbp is just a debug printer, takes the same arguments as print(), but adds file=sys.stderr so that its output is redirected there. It's not completely necessary to comment it out into a pass since the judge evaluates stdout, but I sometimes do it anyway depending on how cluttered the output looks 'after' debugging. Even if it's an empty/pass function, it can get sent some pretty gnarly stuff that still takes resources to construct, in which case it's better to get rid of the call itself.

      If you've broken things out into specific/small enough functions, calling dbp(locals()) will send the dictionary of local variables according to the caller's scope... early on, I got desperate to avoid typing things like dbp('var1:', var1) over and over... that's what I settled on (didn't find C-style macro or wasn't desperate enough).