C137's blog

By C137, history, 4 years ago, In English

Hello Codeforces

I decided to share this article about stress testing after watching the last screencast made by Errichto. To be more precise when he started making stress testing to find counter-test. You can check that here. Errichto has a full video called How to test your solution in Competitive Programming, on Linux? I highly recommend you to check it, basically this article is the same but I am extending it to stress test solutions with multiple answers using a written checker, and I thought maybe you like written articles more than watching videos (some people do).

You can find the article here. I hope you will like it, please share with me your thoughts and if you use other helpful tools then you can share them in the comments below.

You can also check some of my previously written articles about Competitive Programming at:

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

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

Is there a way to stop the bash script if one of the 3 files being compiled returned an error. When one of the files doesn't compile there is no point running the rest of the script right?

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

    Sure, you can kill the script at any time using Ctrl + C

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

      Add "set -e" at the beginning of the script file, it means: "if any command exits with non-zero status, which make/g++ commands do in case of compile error, the script will instantly terminate". This also means if generator/one of stresstested solutions crashes the script terminates instantly.

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

        Added, thanks for pointing at it.

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

        Thanks for sharing, this is a cool method I didn't know about.

        Alternative method I use in case anyone is interested:

        In bash (and most other scripting languages I suppose), the variable $? contains the exit condition of the previously run program, so you can just have a break condition in the script which triggers if the variable is non-zero after the execution. However yeah, set -e does seem to be a better way to do it. Also if you're running this directly from the terminal instead of from a script file, don't forget to do set +e at the end to disable it.

        Also one other small note (for the author), I'd be careful using the "-w" option for diff, missing whitespace may not always result in the correct answer.

        Edit: Also completely unrelated rant, why does mathjax still parse {backslash}{dollar sign} some text {backslash}{dollar sign}...

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

          Most good online judges ignore extra whitespaces, but I think you are right, I will point for that just to be careful while using it.

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

            Removing extra whitespaces is mostly fine, you'll usually only get WA on samples in the worst case which usually isn't be a penalty. But consider a question where you have to print two space separated numbers to the output. Say the answer is 10 11, if the code somehow prints a wrong answer 101 1 the diff won't complain if you're using -w.

            Possibly using -Z instead to remove trailing spaces might be a better idea.

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

Also is there any reason you use rand() over mt19937?

rand() has its problems, mt19937 is much faster and its quite often easier to use it with uniform_int_distribution or similar.

»
21 month(s) ago, # |
  Vote: I like it -10 Vote: I do not like it

The link for the second problem is incorrect in the blog.