Блог пользователя Sandip_Jana

Автор Sandip_Jana, история, 8 лет назад, По-английски

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...!

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
8 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

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

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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 лет назад, # ^ |
        Проголосовать: нравится +1 Проголосовать: не нравится

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

      java.exe -Xmx512M -Xss64M -DONLINE_JUDGE=true -Duser.language=en -Duser.region=US -Duser.variant=US -jar %s
      
      • »
        »
        »
        »
        8 лет назад, # ^ |
        Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

        Thanks fr the help.

        ![ ](http://mirror.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://mirror.codeforces.com/8a367c/Screenshot (286).png)

        div286C is the name of the classfile

        Am i missing something??

        • »
          »
          »
          »
          »
          8 лет назад, # ^ |
            Проголосовать: нравится +1 Проголосовать: не нравится

          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 лет назад, # ^ |
              Проголосовать: нравится 0 Проголосовать: не нравится

            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 .. !