Sandip_Jana's blog

By Sandip_Jana, history, 8 years ago, In English

Problem C : Mr. Kitayuta, the Treasure Hunter

I was trying to solve this Problem on codeforces but when i was trying to solve it in my laptop it gave me StackOverflow error even for small inputs.

I wrote the code in Sublime Text and run it using command prompt

I tried running the same code on Eclipse IDE but in vain . Got the same StackOverflowError .

I checked other people's AC codes and found that logic was same . So i tried submitting the code on codeforces and to my surprise it got AC.

Submitted Solution :- 21278829

Do i need to create a thread and initialize something or something is wrong with the memory. I am unable to figure out the mistake why the program is not executing successfully in my laptop. If someone knows what might be the appropriate solution it would be helpful...!

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

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
8 years ago, # |
  Vote: I like it +1 Vote: I do not like it

I guess your recursion limit is exceeded. On codeforces they add flags to increase it, you can find it.

  • »
    »
    8 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    So is there any feasible way to run the code in my system. Because during live contest i need to check whether my output is correct or not for similar questions. Thanks fr the help :)

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

      http://codeforces.com/blog/entry/79

      java.exe -Xmx512M -Xss64M -DONLINE_JUDGE=true -Duser.language=en -Duser.region=US -Duser.variant=US -jar %s
      
      • »
        »
        »
        »
        8 years ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        Thanks fr the help.

        ![ ](http://codeforces.com/a3c3e3/Screenshot (285).png)

        I tried what is said but in vain.

        java.exe div286C -Xmx512M -Xss64M -DONLINE_JUDGE=true -Duser.language=en -Duser.region=US -Duser.variant=US -jar %s

        I also tried running it using the command simply

        java div286C -Xmx512m -Xss64m

        but still showing same

        ![ ](http://codeforces.com/8a367c/Screenshot (286).png)

        div286C is the name of the classfile

        Am i missing something??

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

          I suppose that Xss means stack size. Your solution uses 98MB for smallest testcases, so maybe try increasing the value to -Xss128m or even more?

          • »
            »
            »
            »
            »
            »
            8 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            I used this command in cmd :

            java div286C -Xmx512M -Xss512m

            Yess -Xss is for increasing the stack size. I tried using -Xss128M and even -Xss512M but still it gave me StackOverflow. Dont know how the other people who actually solved it using the same approach tested their codes. Is there a maximum bound to this Stack Size that i can give?? I tried increasing it to high values but i couldn't possibly figure out anything reasonable that could be of help .. !