Overview
Thecmp command verifies the correctness of your optimized solution by comparing its output against a slower but proven-correct brute-force implementation across multiple randomly generated test cases.
This is the most common stress testing mode for competitive programming, allowing you to catch edge cases that your optimized solution might handle incorrectly.
Basic Usage
Required Parameters
Your optimized solution file to test. Can be any supported language (C++, Java, Python, Rust, Go, C, Kotlin).Short form:
-tThe brute-force or known-correct reference implementation. This solution should always produce correct output, even if it’s slower.Short form:
-cRandom test case generator file. Generates input data for testing.Short form:
-gDefault: "" (empty - can use --prefix instead)The generator and prefix options are mutually exclusive. Use either
--gen-file for random generation or --prefix to run existing test cases.Optional Parameters
Number of test cases to generate and run.Alias:
--tcMaximum execution time per test case in milliseconds.Alias:
--toutMemory limit in bytes (default is 1GB).Alias:
--mlPath prefix for existing test case files. Use this to run against pre-existing test cases instead of generating random ones.Short form:
-pConflicts with: --gen-fileShow detailed differences between expected output and actual output when tests fail.Short form:
-dControl Flags
Stop execution immediately when a WA (Wrong Answer), TLE (Time Limit Exceeded), or RTE (Runtime Error) occurs.Aliases:
--break, -bSave Options
Save only test cases that fail (WA, TLE, RTE, MLE states).
Save all test cases regardless of their result.
Run Filters
Use these flags to run specific subsets of previously saved test cases:Run all saved test cases.
Run only test cases that previously passed (Accepted status).
Run only test cases that previously failed with Wrong Answer.
Run only test cases that previously exceeded time limit.
Run only test cases that previously exceeded memory limit.
Run only test cases that previously had runtime errors.
Examples
Basic Comparison Test
Save and Debug Failed Cases
Maximum Subarray Problem Example
Here’s a complete example testing an optimized Maximum Subarray solution:Using Existing Test Cases
Run against pre-existing test files:Understanding Test Results
QuickTest displays real-time results with status indicators:- AC - Accepted (correct answer)
- WA - Wrong Answer
- TLE - Time Limit Exceeded
- MLE - Memory Limit Exceeded
- RTE - Runtime Error