acmx
acmx copied to clipboard
Adaptive checker (to handle float precision error)
Default checker used atm is wcmp which is great to compare tokens and ignore trailing whitespaces and EOL (also similar checkers are commonly used on several platforms, primarily Codeforces).
But another common checker is using decimal numbers and allowing some margin for mistake (1e-7
).
Proposoal: Use an hybrid of wcmp
where if token comparation fails, try to read both token as doubles
and check whether precision is below some threshold. This idea rarely will give some false positive, and will automatically work for test cases that requires a decimal number where some error is allowed.
Wouldn't this be very slow?
Wouldn't this be very slow?
Why do you think that would be the case? The idea is that for every token we compare if they are equal, if that check fails, then we try to convert to double and check if both are at most some epsilon apart from each other, if it fails to convert to double or they are not that close, then we finish checker and report Wrong Answer.
I propose to use same code from wcmp
but adding this one more check. I don't think it will create any noticeable overhead.