Safrout's blog

By Safrout, 10 years ago, In English

I was solving this problem on SPOJ

http://www.spoj.com/problems/STRSOCU/

I got a c++ code accepted but the same code written in java gives NZEC error

here is my java code

Why should this code give an NZEC error??

http://ideone.com/eZ9BYM

  • Vote: I like it
  • 0
  • Vote: I do not like it

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

Don't close out.

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

    Still NZEC

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

      Can't to[p].get(c) be null on Line 45?

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

        updated the code

        refresh the link

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

          But you are still closing out. UPD: Oh, I think I'm mistaken, spoj wouldn't allow you to close bf, out is ok.

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

        but it still gives NZEC

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

          I think I've got it. The default stack size is too small for Java on spoj. See this thread: http://codeforces.net/blog/entry/166.

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

            I thought at the first glance that this might be the problem but I needed to make sure that there are no other problems.

            I think I may spend sometime later to simulate the recursion with a stack or do the thread thingy if I am going to accept it with java.

            Thank you so much :D .

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

            LOOOOL.

            I got it accepted by the help of that blog entry.

            I set the size of the stack by myself for a thread.

            Thank you so much :D .

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

            I didn't ever imagined that I can control the memory's Stack size in java.

            LOL