If you have written some tasks, and have prepared test cases, you will probably experience the terrible feeling that some test cases may be invalid (meaning it does not agree with the constraints in problem statement): upper bound can be violated, your graph not satisfied connectivity requirements or is not at tree. It is a reasonable to feel that way. Even experienced problem setters make mistakes sometimes (for example, in the pretigious ACM ICPC World final 2007).
The validator in testlib is a good tool to help you prevent such mistakes. It is very easy to use.
Example
Following is the validator of validator, which I used in a problem I prepared: 100541A - Stock Market:
#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
int main() {
registerValidation();
int test = inf.readInt(1, 10);
inf.readEoln();
while (test--) {
int n = inf.readInt(1, 100);
inf.readChar(' ');
int w = inf.readInt(1, 1000000);
inf.readEoln();
for(int i = 0; i < n; ++i) {
inf.readInt(1, 1000);
if (i < n-1) inf.readChar(' ');
else inf.readEoln();
}
}
inf.readEof();
return 0;
}
List of available methods:
Following is the methods available: * registerValidation * readInt * readEof * readEoln * readChar
[more content to be added]