liboya5074's blog

By liboya5074, history, 15 months ago, In English

I recently realized that nearly all problems in codeforces have multiple test cases in a single test, which makes my code ugly and annoying.

I wonder why codeforces set multiple cases in a single test?

I know some OJs will do this because they don't have better machine to run many divided cases. But it is obvious that codeforces' judger runs well.

In some contest rules they set multiple cases in order that participants can't get unexpected points through tricks, like presenting only "Yes" or "No", or print a random number. But codeforces' rule doesn't work like this.

So is it a tradition to do so or for other reason?

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

| Write comment?
»
15 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The first idea that comes to mind is that you are limited on how many pretests you can run depending on what letter the problem is. A div2A, for example, only gets 4 pretests, meaning multi-testing is essentially required. If you want to make your code cleaner, you can simply extract your code into a solve() function and have testcase handling at the bottom of your code.

Additionally, while I'm not familiar with codeforces' setup, I would presume that single-tests don't provide too much overhead in terms of performance, though I can't be certain about that.

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

    Thanks. But after all, every case has an promise of testdata, which is, in its size, quite close to the overall sum of size.

    for example, "the sum of N for all test cases does not exceed 2e5"

    while "contains a positive number N (2 <= N <= 2e5)"

    so will it simpler to merge all cases into one?

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

      I believe that constraint allows for large tests but also allows the author to test a lot of smaller test cases as well without having to make 1000 tests.

»
15 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Read this polygon rules. It states that every problem MUST have multiple tests. It also states that the number of test cases for problems before D2E is limited, so multiple tests are needed to exclude wrong solutions.