gigabuffoon's blog

By gigabuffoon, history, 7 years ago, In English

In today's Round #449, I received a MLE verdict on C in system testing. At first, I thought it was because of how much stack space I allocated. But Java should allocate memory as necessary, and I was only using it for recursion, so I found it odd that I would MLE.

So, I resubmitted my code and made the following change:

That code was accepted. No change was made other than the addition of the comment. The two submissions are listed below for reference. MikeMirzayanov, what's good?

MLE: http://codeforces.me/contest/897/submission/32866893

AC: http://codeforces.me/contest/897/submission/32880052

  • Vote: I like it
  • +58
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it +17 Vote: I do not like it

what's even stranger is that you used even MORE memory in the code that got AC...

»
7 years ago, # |
  Vote: I like it +13 Vote: I do not like it

You know what they say, second time's the charm.

»
7 years ago, # |
Rev. 3   Vote: I like it +16 Vote: I do not like it

Just to be clear, literally submitting the exact same code from your in contest submission gets AC (http://codeforces.me/contest/897/submission/32880815) with 20248 KB of memory.

Interestingly, the in contest submission only uses 20140 KB on the test case it MLE's on, and uses 30316 KB on an earlier case. Maybe the exception returned wasn't really an MLE:

java.lang.OutOfMemoryError: unable to create new native thread
	at java.lang.Thread.start0(Native Method)
	at java.lang.Thread.start(Thread.java:717)
	at Main.main(Main.java:16)

It looks to me like this is an exception returned when the OS won't allow the JVM to create any more threads (see https://stackoverflow.com/questions/16789288/java-lang-outofmemoryerror-unable-to-create-new-native-thread), yet you're only creating one extra thread (which is normally allowed). Maybe this is an issue with the server running your code being overloaded?

»
7 years ago, # |
  Vote: I like it +55 Vote: I do not like it

I'll look into it soon.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +12 Vote: I do not like it

    Thank you so much for updating the contest results to reflect the corrected submission. Your attention to community is awesome. Out of curiosity, did you figure out what the issue was? Was the above hypothesis correct?