From 587a3c7c8a561e0cd62dd1e0ca49747fc5ada0f8 Mon Sep 17 00:00:00 2001 From: Keenan Gugeler Date: Sat, 12 Mar 2022 17:01:13 -0500 Subject: [PATCH] judge: pass full `result` to checkers --- dmoj/graders/standard.py | 1 + testsuite/check_memory_limit/checker.py | 9 +++++++++ testsuite/check_memory_limit/init.yml | 4 ++++ testsuite/check_memory_limit/tests/cpp_blank/empty.cpp | 1 + testsuite/check_memory_limit/tests/cpp_blank/test.yml | 5 +++++ .../tests/cpp_too_much_memory/bloat.cpp | 8 ++++++++ .../tests/cpp_too_much_memory/test.yml | 5 +++++ 7 files changed, 33 insertions(+) create mode 100644 testsuite/check_memory_limit/checker.py create mode 100644 testsuite/check_memory_limit/init.yml create mode 100644 testsuite/check_memory_limit/tests/cpp_blank/empty.cpp create mode 100644 testsuite/check_memory_limit/tests/cpp_blank/test.yml create mode 100644 testsuite/check_memory_limit/tests/cpp_too_much_memory/bloat.cpp create mode 100644 testsuite/check_memory_limit/tests/cpp_too_much_memory/test.yml diff --git a/dmoj/graders/standard.py b/dmoj/graders/standard.py index c7ff0dabd..ab3bd2925 100644 --- a/dmoj/graders/standard.py +++ b/dmoj/graders/standard.py @@ -63,6 +63,7 @@ def check_result(self, case, result): binary_data=case.has_binary_data, execution_time=result.execution_time, problem_id=self.problem.id, + result=result, ) except UnicodeDecodeError: # Don't rely on problemsetters to do sane things when it comes to Unicode handling, so diff --git a/testsuite/check_memory_limit/checker.py b/testsuite/check_memory_limit/checker.py new file mode 100644 index 000000000..83617d52b --- /dev/null +++ b/testsuite/check_memory_limit/checker.py @@ -0,0 +1,9 @@ +from dmoj.checkers import standard +from dmoj.result import Result + + +def check(process_output: bytes, judge_output: bytes, *, result: Result, **kwargs) -> bool: + if result.max_memory > 16384: + return False + + return standard.check(process_output, judge_output, result=result, **kwargs) diff --git a/testsuite/check_memory_limit/init.yml b/testsuite/check_memory_limit/init.yml new file mode 100644 index 000000000..aa96ba792 --- /dev/null +++ b/testsuite/check_memory_limit/init.yml @@ -0,0 +1,4 @@ +checker: checker.py +points: 1 +test_cases: + - {} diff --git a/testsuite/check_memory_limit/tests/cpp_blank/empty.cpp b/testsuite/check_memory_limit/tests/cpp_blank/empty.cpp new file mode 100644 index 000000000..237c8ce18 --- /dev/null +++ b/testsuite/check_memory_limit/tests/cpp_blank/empty.cpp @@ -0,0 +1 @@ +int main() {} diff --git a/testsuite/check_memory_limit/tests/cpp_blank/test.yml b/testsuite/check_memory_limit/tests/cpp_blank/test.yml new file mode 100644 index 000000000..45ae2944f --- /dev/null +++ b/testsuite/check_memory_limit/tests/cpp_blank/test.yml @@ -0,0 +1,5 @@ +language: CPP11 +time: 2 +memory: 65536 +source: empty.cpp +expect: AC diff --git a/testsuite/check_memory_limit/tests/cpp_too_much_memory/bloat.cpp b/testsuite/check_memory_limit/tests/cpp_too_much_memory/bloat.cpp new file mode 100644 index 000000000..702805942 --- /dev/null +++ b/testsuite/check_memory_limit/tests/cpp_too_much_memory/bloat.cpp @@ -0,0 +1,8 @@ +#pragma GCC optimize "O0" + +const int MN = 25 * 1024 * 1024; +char arr[MN]; +int main() { + for (int i = 0; i < MN; ++i) + arr[i] = ' '; +} diff --git a/testsuite/check_memory_limit/tests/cpp_too_much_memory/test.yml b/testsuite/check_memory_limit/tests/cpp_too_much_memory/test.yml new file mode 100644 index 000000000..65d4c9f51 --- /dev/null +++ b/testsuite/check_memory_limit/tests/cpp_too_much_memory/test.yml @@ -0,0 +1,5 @@ +language: CPP11 +time: 2 +memory: 65536 +source: bloat.cpp +expect: WA