Custom Checker

    Example Custom Checker


    #include <stdio.h>
    #include <stdlib.h>
    int main() {
        // File input.txt contains the judge input for current test case.   
        FILE *input;
        input = fopen("input.txt", "r");
        // File output.txt contains the output of the submitted code.
        // This is essentially the contents of stdout obtained by running the
        // submitted code for the current test case with the contents of the
        // above input.txt file as its stdin.
        FILE *output;
        output = fopen("output.txt", "r");
        // File answer.txt contains the judge output for current test case.
        // When authoring a problem, it is absolutely essential to provide a
        // valid and correct judge output even if custom checker code is 
        // sufficient on its own to determine the correctness of output.txt. 
        // This is because Toph determines the output limit based on the judge
        // output file for any test case (output limit is roughly twice the
        // number of bytes of this answer.txt file).
        FILE *answer;
        answer = fopen("answer.txt", "r");
        // Additionally, the source code of the submission itself will be
        // available in the current directory as source.txt.
        // Once the three files are open, you will need to check if the
        // contents of the output.txt file is correct.
        // ... check correctness here
        // If contents of output.txt is found to be correct, print a single
        // line to stdout with a single integer: 0. Otherwise print a positive
        // integer indicating the number of differences found. The exact value
        // is not of critical importance as any non-zero positive integer will
        // cause Toph to award the submission a Wrong Answer verdict - but the
        // the number itself will show up in the difference column in the back
        // submission view (only visible to admins and contest moderators).
        int n;
        printf("%d\n", n);
        return 0;

    At the end, you need to print a single integer from the custom checker. If the integer is 0, it implies that the submitted program behaved in an expected way (i.e. the test case passed successfully). Otherwise, you can print a non-zero positive number to indicate that the submitted program failed to produce the correct behavior.