hkbishwa's blog

By hkbishwa, history, 4 months ago, In English,

Hello, codeforces community!

I am recently working on a project of building a Online Judge using Java and my minimum target was at least to make sure that it can detect the four most popular verdicts in Competitive Programming world. I somehow managed to implement AC, WA, TLE. But I am at a loss how to handle Runtime Error. For most of the cases, my program takes RE as TLE. I am just curious to know how can one determine Runtime Error effectively. I would love to have some idea about it and which can be a better a platform than CF community!

Thanks to all in advance.

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

»
4 months ago, # |
  Vote: I like it +1 Vote: I do not like it

Check the return value of the process. If it is non-zero, it is RTE.

  • »
    »
    4 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thank you. I tried it but for a c code with a simple 1/0 statement it took 40 sec to terminate and return a non-zero value :(

»
4 months ago, # |
  Vote: I like it 0 Vote: I do not like it

When a runtime error occurs the output will be null. So check if the output is null or not. that's it.

  • »
    »
    4 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I'm afraid I could not get the meaning of "output" in your comment. what did you mean by output? Can you please elaborate ?

    If you mean by "output" the output of the program submitted by the client against judge data, then what about the case when the code will get a TLE? Because in this case the output will also be a null, I think. Am I right?

    Please clarify :D

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

      No. During TLE you will get partial output and it will cross problem time limit. But During Runtime Error No output will be generated that means it will return null value. So at first check what your compile returns. if the result is totally null then it is run time error else if the total execution time is crossed problem time limit then tle .

      • »
        »
        »
        »
        4 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        But During Runtime Error No output will be generated that means it will return null value

        Really???
        https://ideone.com/rbmLb0
        https://ideone.com/C8BQeY

        • »
          »
          »
          »
          »
          4 months ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          final output will be generated after all operation. you have printed before run time and after run time output 6 has not printed.

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

            What do you mean by final output?? It printed at least something right?

          • »
            »
            »
            »
            »
            »
            4 months ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            if the result is totally null then it is run time error

            It's not totally null. Isn't it??

            • »
              »
              »
              »
              »
              »
              »
              4 months ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              Yes. It prints before occurring run time error but it does not print anything after run time error. So i am just talking about what will happen after run time error.

»
4 months ago, # |
  Vote: I like it +1 Vote: I do not like it

If you are in Linux and coding in python, you can use this script: https://ideone.com/jHoSRD
It can handle all the things. (observe from line 42).

»
4 months ago, # |
  Vote: I like it +1 Vote: I do not like it

I have no much experience in this but you can do it by trick First check for TLE then terminate the program and check for the output because most problem doesn't exceed 15 second