### CantGetAnyWaWhyIamSoWise's blog

By CantGetAnyWaWhyIamSoWise, 4 years ago, translation,

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.

• +10

 » 4 years ago, # |   0 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, # |   0 Auto comment: topic has been translated by CantGetAnyWaWhyIamSoWise (original revision, translated revision, compare)
 » 4 years ago, # |   0 Auto comment: topic has been updated by CantGetAnyWaWhyIamSoWise (previous revision, new revision, compare).
 » 4 years ago, # |   0 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, # ^ |   0 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, # ^ |   +5 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, # ^ |   0 freopen worked. But it's showing accepted for any case with lower score. Btw, thank you
 » 4 years ago, # | ← Rev. 2 →   +5 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, # ^ |   0 Amazing. I couldn't find information about checker for a long time, thank you.
•  » » 4 years ago, # ^ |   0 Why I can't erase their template for custom checkers?
•  » » » 4 years ago, # ^ |   0 I don't understand this question. Do you mean that you can't upload your own code?
•  » » » » 4 years ago, # ^ |   0 Yes. I can't add own checker.There I've two non-editable parts of checker head and tail. Information from link
•  » » » » » 4 years ago, # ^ |   0 What about this tab: https://i.imgsafe.org/4ae9837f31.png
•  » » » » » » 4 years ago, # ^ |   0 Your tab looks like different from mine:https://i.imgsafe.org/4b10b56947.pngWhy?
•  » » » » » » » 4 years ago, # ^ |   0 Apparently they changed something recently. In my old problems I see an editable code. I've just created a new empty problem and there I see the same fixed code as in your screenshot. You should try to reach someone from Hackerrank to ask about it. Likely now you must use a code with json.
•  » » » » » » » » 4 years ago, # ^ |   0 I've understood. Thank you
•  » » » » » » » » » 4 years ago, # ^ | ← Rev. 2 →   -17 delete
 » 4 years ago, # |   0 Our custom checker was recently updated, please see the documentation here.
•  » » 3 weeks ago, # ^ |   0 Yeah but it still doesn't has any documentation for C++