CantGetAnyWaWhyIamSoWise's blog

By CantGetAnyWaWhyIamSoWise, 4 years ago, translation, In English

I want to manage challange on HACKERRANK (some old COCI, usaco .. -- problems), but I encounter with checker problem. If problem have more than 1 correct answer, how to write checker for that case? Could you show some examples (C++) ?

UPD0 I found that for problems with more than 1 correct answer, we must write checker like for approximation problems. Is it true? Could you show some examples (C++) ?

UPD1 hackerrank.com hasn't got a checker tab like polygon. It has only custom checker, but this checker doesn't use testlib. And this checker for approximation problems.

P.S Checker looks like this. I have no idea how to use this.

UPD2 Errichto and yeputons thank you for your help.

 
 
 
 
  • Vote: I like it
  • +10
  • Vote: I do not like it

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I'm not sure about HackerCup's conventions for checkers, but Codeforces (and almost all major Russian competitions) use testlib for writing checkers/validators/generators. You can either look at these links (blog posts from Codeforces' team) or go straight to the repository. There are some examples both in the repository and in blog posts as well.

Reasons to not write your own checker: you'll probably forget to handle some very extreme cases or will handle them incorrectly (e.g. with floating point numbers). Checker should be bulletproof.

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been translated by CantGetAnyWaWhyIamSoWise (original revision, translated revision, compare)

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by CantGetAnyWaWhyIamSoWise (previous revision, new revision, compare).

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Judging by this link I'd suggest that you should take the source code "as is" and change the void run_custom_checker(const TestStruct t_obj, ResultStruct &r_obj) function. It takes some information about the run in t_obj (format is described above: there are fields which specify path to different files like input/output/expected output) and should output judging result in the r_obj structure. I believe that score and message fields are self-documented, and I assume that result should true/false depending on whether the test is "passed" in some sense. E.g. for ACM ICPC-style problems it's equal to score (and score can be either 0 or 1), and for some problems with continuous scoring it's probably whether or not participant's answer is correct in some sense.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I've stuck with const TestStruct t_obj. How I can take the test case, if I have path for it? With freopen ? Like this:

    freopen(t_obj.testcase_input_path.c_str(),"r",stdin); ?
    

    Can't I give different score for different tests ?

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it +5 Vote: I do not like it

      Yup, I believe freopen should work.

      I believe you should be able to set any score for any test by setting the score field. Not sure, though.

»
4 years ago, # |
Rev. 2   Vote: I like it +5 Vote: I do not like it

It's possible to write a simple C++ checker. I used something like this: http://ideone.com/cnKlcQ.

EDIT: Maybe it's impossible to use this kind of checker anymore, see comments below.

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Our custom checker was recently updated, please see the documentation here.

  • »
    »
    3 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yeah but it still doesn't has any documentation for C++