Overview
Thecheck command validates your solution using a custom checker script instead of direct output comparison. This is essential for problems where multiple correct answers exist, making simple string comparison inadequate.
Use
check when a problem accepts multiple valid solutions (e.g., “find any valid pair”, “output any permutation that satisfies”, etc.)Basic Usage
Required Parameters
Your solution file to validate. Can be any supported language (C++, Java, Python, Rust, Go, C, Kotlin).Short form:
-tThe checker script that validates whether the solution’s output is correct. This script receives the input and your solution’s output, then outputs “YES” or “NO”.Short form:
-cRandom test case generator file.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.Short form:
-pConflicts with: --gen-fileControl 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.
How Checkers Work
A checker script must:- Read the original input (typically from
.qt/input.txt) - Read your solution’s output from stdin
- Validate the output meets problem constraints
- Output “YES” if valid, “NO” otherwise
Examples
Basic Checker Test
Multiplication Problem Example
Problem: Givenn, output two numbers that multiply to n.
Debug Failed Validations
Manually inspect saved cases
Check the saved test case files to understand what inputs cause failures.
Graph Problem Example
Problem: Output any valid Hamiltonian path in a graph (many solutions exist).Using Existing Test Cases
Save All for Analysis
Save all test cases to study the variety of valid solutions:Checker Best Practices
Common Use Cases
Multiple Valid Answers
Problems asking for “any” valid solution
Approximate Solutions
Answers within an epsilon tolerance
Construction Problems
Build any structure meeting criteria
Permutation Problems
Any valid ordering or arrangement
Understanding Test Results
QuickTest displays real-time results:- AC - Accepted (checker returned YES)
- WA - Wrong Answer (checker returned NO)
- TLE - Time Limit Exceeded
- MLE - Memory Limit Exceeded
- RTE - Runtime Error