NeverMa573r's blog

By NeverMa573r, history, 17 months ago, In English

Just curious, do problem setters create some test cases by hand and then randomly generate the rest or are all the test cases just randomly generated within the bounds of the problem?

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

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

There are different methods to generate a test case. Usually another code is written to generate random numbers within a given constraint and then printed into a file which is uploaded.

But sometimes smaller edge cases are manually written.

»
17 months ago, # |
  Vote: I like it +25 Vote: I do not like it

Some tests are made by hand, however most are randomly generated. This doesn't mean that the tests are completely random, as they would be very weak.

For example, 1784C — Zero Sum Prefixes has 8 distinct test generators.

The one that was used for the most testcases is this one:

Code

It takes the number of testcases, the maximum sum of $$$n$$$ across all testcases, the probability of an element being equal to $$$0$$$ and a bucket as parameters.

This generator works based on the intended solution. In each subarray delimited by two zeroes, we can have at most bucket distinct prefix sums. The reasoning for this is that if the bucket size is smaller, the answer will be larger, and vice-versa.