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.
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.
Auto comment: topic has been translated by CantGetAnyWaWhyIamSoWise (original revision, translated revision, compare)
Auto comment: topic has been updated by CantGetAnyWaWhyIamSoWise (previous revision, new revision, compare).
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 int_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 ther_obj
structure. I believe thatscore
andmessage
fields are self-documented, and I assume thatresult
should true/false depending on whether the test is "passed" in some sense. E.g. for ACM ICPC-style problems it's equal toscore
(andscore
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.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:Can't I give different score for different tests ?
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.freopen worked. But it's showing accepted for any case with lower score. Btw, thank you
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.
Amazing. I couldn't find information about checker for a long time, thank you.
Why I can't erase their template for custom checkers?
I don't understand this question. Do you mean that you can't upload your own code?
Yes. I can't add own checker.
There I've two non-editable parts of checker head and tail. Information from link
What about this tab: https://i.imgsafe.org/4ae9837f31.png
Your tab looks like different from mine:
https://i.imgsafe.org/4b10b56947.png
Why?
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.
I've understood. Thank you
Our custom checker was recently updated, please see the documentation here.