Hi, can anyone tell if there's a way to stress test solution to an interactive problem by running it over hundreds of test cases ?
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | maomao90 | 163 |
2 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
Hi, can anyone tell if there's a way to stress test solution to an interactive problem by running it over hundreds of test cases ?
Name |
---|
It’s quite difficult and perhaps someone out there has a catch-all way, but for me I tend to take a copy of my code, and loop over it for a series of predefined tests, with a naive function which replaces the queries and responses. In this naive function I would deterministically calculate the ‘responses’ to my own queries instead of receiving them as inputs.
Limitations:
1) naive functions usually only work on smaller inputs so it probably wouldn’t be able to test larger test cases
2) there may be bugs in the naive function, or other problems introduced by slightly modifying the code
3) this only works for interactive problems where there actually is a deterministic answer. Sometimes (especially in contests like Google Code Jam) you may find that heuristics are appropriate (e.g. if a 90% success rate is the target), or the response has a random element to it. This is much trickier
Google actually develops an ‘interactive runner’ for each of its interactive problems, which runs some cases for you. You could also look to modify that for your specific purposes, but the code is not trivial.
I don't do this during short contests, but on a long challenge I once used Polygon to run stress tests.
This is so smart, WOW
I think if you've had a prewritten task for it the process would be nearly as fast as regular stress-testing.
First generate your testcases based on the hack format in the problem. Then write an interactor. Finally replace all your io with functions which you can then replace with function calls to your interactor.