diff --git a/locale/vi/LC_MESSAGES/django.po b/locale/vi/LC_MESSAGES/django.po index 3640af2..9c5db79 100644 --- a/locale/vi/LC_MESSAGES/django.po +++ b/locale/vi/LC_MESSAGES/django.po @@ -34,7 +34,7 @@ msgstr "bình luận" #: chat_box/views.py:41 msgid "Chat Box" -msgstr "Khu Tâm Sự" +msgstr "Khu Trò Chuyện" #: dmoj/settings.py:349 msgid "German" diff --git a/templates/about/custom-checker-sample.html b/templates/about/custom-checker-sample.html index c3bb67f..ebbf580 100644 --- a/templates/about/custom-checker-sample.html +++ b/templates/about/custom-checker-sample.html @@ -98,10 +98,18 @@ main.exe [input_file] [output_file] [ans_file]
- Chương trình trả về giá trị 0 nếu AC, 1 nếu WA. Những thông tin được viết ra stdout (bằng cout) sẽ được in ra màn hình cho người nộp bài(feedback) + Chương trình trả về giá trị: +
Chương trình sau dùng để chấm bài toán: Cho n là một số nguyên dương. In ra hai số tự nhiên a, b sao cho a + b = n.
+Nếu in ra a + b = n và a, b >= 0 thì được 100% số điểm, nếu a + b = n nhưng một trong 2 số a, b âm thì được 50% số điểm.
#include <bits/stdc++.h> using namespace std; @@ -119,7 +127,14 @@ int main(int argc, char** argv) { if (a + b == c + d) { cout << a << " + " << b << " = " << c << " + " << d << endl; - return 0; // AC + + if (a >= 0 && b >= 0) { + return 0; // AC + } + else { + cerr << 0.5; + return 2; // PARTIAL + } } else { cout << "a + b = " << a + b << " != " << n << endl; diff --git a/templates/submission/status-testcases.html b/templates/submission/status-testcases.html index d46b58d..f37eb79 100644 --- a/templates/submission/status-testcases.html +++ b/templates/submission/status-testcases.html @@ -55,7 +55,7 @@{{submission.long_status}} {{_('Point: ')}} - {{ submission.case_points|floatformat(0) }}/{{ submission.case_total|floatformat(0) }} + {{ submission.case_points|floatformat(1) }}/{{ submission.case_total|floatformat(0) }} @@ -96,7 +96,7 @@ {% if not batch.id %} -{{_('Point')}}: {{ case.points|floatformat(0) }}/{{ case.total|floatformat(0) }} +{{_('Point')}}: {{ case.points|floatformat }}/{{ case.total|floatformat(0) }} {% endif %}diff --git a/validator_template/template.py b/validator_template/template.py index c7d8567..c131b9b 100644 --- a/validator_template/template.py +++ b/validator_template/template.py @@ -1,11 +1,10 @@ -import os +import os, re import subprocess -from dmoj.contrib import contrib_modules from dmoj.error import InternalError from dmoj.judgeenv import env, get_problem_root from dmoj.result import CheckerResult -from dmoj.utils.helper_files import compile_with_auxiliary_files, mktemp +from dmoj.utils.helper_files import compile_with_auxiliary_files, mktemp, parse_helper_file_error from dmoj.utils.unicode import utf8text executor = None @@ -23,29 +22,53 @@ def get_executor(files, lang, compiler_time_limit, problem_id): return executor +class Module: + AC = 0 + WA = 1 + PARTIAL = 2 + + # a float from 0 to 1 + repartial = re.compile(r'^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$', re.M) + + @classmethod + def parse_return_code(cls, proc, executor, point_value, time_limit, memory_limit, feedback, name, stderr): + if proc.returncode == cls.AC: + return CheckerResult(True, point_value, feedback=feedback) + elif proc.returncode == cls.PARTIAL: + match = cls.repartial.search(stderr) + if not match: + raise InternalError('Invalid stderr for partial points: %r' % stderr) + points = float(match.group(0)) + if not 0 <= points < 1: + raise InternalError('Invalid partial points: %d' % points) + return CheckerResult(False, points * point_value, feedback=feedback) + elif proc.returncode == cls.WA: + return CheckerResult(False, 0, feedback=feedback) + else: + parse_helper_file_error(proc, executor, name, stderr, time_limit, memory_limit) + def check(process_output, judge_output, judge_input, problem_id={{problemid}}, files={{filecpp}}, lang='CPP14', time_limit=10, - memory_limit=1024**2, + memory_limit=1024 * 512, compiler_time_limit=30, - feedback=True, type='default', + feedback=True, point_value=None, **kwargs) -> CheckerResult: executor = get_executor(files, lang, compiler_time_limit, problem_id) - if type not in contrib_modules: - raise InternalError('%s is not a valid return code parser' % type) - with mktemp(judge_input) as input_file, mktemp(process_output) as output_file, mktemp(judge_output) as judge_file: - process = executor.launch(input_file.name, output_file.name, judge_file.name, stdout=subprocess.PIPE, + try: + process = executor.launch(input_file.name, output_file.name, judge_file.name, stdout=subprocess.PIPE, stderr=subprocess.PIPE, memory=memory_limit, time=time_limit) + proc_output, error = map(utf8text, process.communicate()) + except Exception as err: + raise InternalError('Error while running checker: %r', err) - proc_output, error = map(utf8text, process.communicate()) - - return contrib_modules[type].ContribModule.parse_return_code(process, executor, point_value, time_limit, - memory_limit, - feedback=utf8text(proc_output) - if feedback else None, name='checker', - stderr=error) \ No newline at end of file + return Module.parse_return_code(process, executor, point_value, time_limit, + memory_limit, + feedback=utf8text(proc_output) + if feedback else None, name='checker', + stderr=error) \ No newline at end of file