Catches wrong answers by comparing your optimised solution against a brute force on random inputs.
| File | Purpose | Edit per problem? |
|---|---|---|
gen.cpp |
Random input generator | ✅ make_test() only |
solution.cpp |
Your optimised solution | ✅ |
brute.cpp |
Your correct brute force | ✅ |
stress.bat |
Test runner | ❌ |
After running, these folders are created automatically:
build\ <- compiled binaries
dump\ <- temporary I/O files (auto-cleaned after each run)
result\ <- saved inputs and outputs from failing tests
stress.bat :: 1000 tests, compiles everything
stress.bat 500 :: 500 tests
stress.bat 500 0 :: 500 tests, skip recompileThe input, your output, and the expected output are printed directly in cmd. After pressing any key they are saved to:
result\fail_input.txt
result\fail_output.txt
result\fail_expected.txt
result\fail_seed.txt
To replay the exact failing input at any time:
build\gen <seed> > dump\input.txt
build\solution < dump\input.txtIf solution.exe or brute.exe exits with a non-zero code (segfault, failed assert, out of bounds), the run stops immediately with the input printed and saved to result\.
The only part you edit per problem is make_test(). Everything else is reusable across problems.
void make_test()
{
int n = get(1, 100);
auto a = get_array<int>(n, 1, 1000);
cout << n << "\n";
for (int i = 0; i < n; i++)
cout << a[i] << " \n"[i == n - 1];
}For multi-test problems, uncomment and configure t in main():
t = get(1, 10);
cout << t << "\n";| Function | Description |
|---|---|
get(l, r) |
Random integer in [l, r], no modulo bias |
get_string(n) |
Random lowercase string of length n |
get_array<T>(n, l, r) |
Random array of n values in [l, r] |
get_permutation(n) |
Random permutation of 1..n |
get_tree(n) |
Random tree, n nodes, 1-indexed, returns edge list |
get_graph(n, m) |
Random simple graph, n nodes, m edges |
stress.bat passes the loop index as the seed to gen automatically. Every test is fully reproducible — seed 47 always produces the same input regardless of when you run it.
1. Write solution.cpp and brute.cpp
2. Edit gen.cpp -> make_test() to match the problem's input format
3. Run stress.bat
4. On mismatch: debug solution.cpp using the saved result\ files
5. Fix and re-run until all tests pass