From 9e95fd21a78e7214a2426d4fcbe379677b0ac9ff Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Tue, 17 Mar 2020 23:57:57 -0600 Subject: [PATCH] fix icon --- 502.html | 6 +- | 5 + dmoj/urls.py | 2 +- templates/about/custom-checker-sample.html | 1209 ++------------------ 4 files changed, 135 insertions(+), 1087 deletions(-) diff --git a/502.html b/502.html index 1529473..4eb512a 100644 --- a/502.html +++ b/502.html @@ -49,14 +49,14 @@



-

But don't worry, we'll be back soon.

+

But don't worry, we'll be back soon.
In the free time, you can read my idol's codes cuom1999

diff --git a/ b/ index 09df016..b001604 100644 --- a/ +++ b/ @@ -4195,3 +4195,8 @@ INFO 2020-03-18 09:35:40,188 judgehandler judge1: Updated problem list INFO 2020-03-18 09:36:11,729 judgehandler judge1: Updated problem list INFO 2020-03-18 09:36:11,832 judgehandler judge1: Updated problem list INFO 2020-03-18 09:36:11,842 judgehandler judge1: Updated problem list +INFO 2020-03-18 09:47:23,140 judgehandler Judge disconnected from: ('127.0.0.1', 51310) +INFO 2020-03-18 09:47:33,189 judgehandler Judge connected from: ('127.0.0.1', 53378) +INFO 2020-03-18 09:47:33,264 judgehandler Judge authenticated: ('127.0.0.1', 53378) (judge1) +INFO 2020-03-18 12:26:36,347 judgehandler judge1: Updated problem list +INFO 2020-03-18 12:26:45,389 judgehandler judge1: Updated problem list diff --git a/dmoj/urls.py b/dmoj/urls.py index 0b960d0..3b96d68 100644 --- a/dmoj/urls.py +++ b/dmoj/urls.py @@ -382,7 +382,7 @@ favicon_paths = ['apple-touch-icon-180x180.png', 'apple-touch-icon-114x114.png', for favicon in favicon_paths: urlpatterns.append(url(r'^%s$' % favicon, RedirectView.as_view( - url=lazystr(lambda: static('icons/' + favicon)), + url=static('icons/' + favicon) ))) handler404 = 'judge.views.error.error404' diff --git a/templates/about/custom-checker-sample.html b/templates/about/custom-checker-sample.html index 91ad799..c3bb67f 100644 --- a/templates/about/custom-checker-sample.html +++ b/templates/about/custom-checker-sample.html @@ -1,1088 +1,131 @@ {% extends "base.html" %} - {% block body %} - custom

Original Document

-

A checker Python script must implement a function that is called by the judge:

-
def check(process_output, judge_output, **kwargs):
-    # return True/False
-
- -

Variables in global scope will exist throughout the grading process.

-

**kwargs is a directory containing

-
    -
  • submission_source: the source code of the submission
  • -
  • judge_input: the judge’s input
  • -
  • point_value: the point value of the test case
  • -
  • case_position: the index of the test case
  • -
  • batch: the batched the test case belongs to
  • -
  • submission_language: the language the submission was submitted in
  • -
  • binary_data: a boolean, which is True if the data was not normalized to Linux line endings, and False otherwise
  • -
  • execution_time: the runtime of the program, in seconds
  • -
-

Additionally, if the check method has the flag run_on_error set, it will be run against the submission’s output, even if it receives an IR/TLE/RTE/MLE verdict. -The only built-in checker that has this flag set is the linecount checker.

-

Return:

-

check can return either a CheckerResult object (from dmoj.result import CheckerResult), or a boolean (case_passed_bool). - A CheckerResult can be instantiated through CheckerResult(case_passed_bool, points_awarded, feedback='').

-

Sample Checker:

-

Here is the checker for the problem: Print 2 integers having sum equal to n (n is read from input).

- - -
+ + + +
+

1. Custom checker (PY)

+
+

+ Đây là checker mặc định của website, cho phép người dùng cập nhật được nhiều thông tin nhất (chi tiết xem ở bên dưới). Chúng ta cần hoàn thành hàm check dưới đây: +

+ +
+def check(process_output, judge_output, **kwargs):
+    # return True/False
+ +

+ Trong đó, **kwargs có thể chứa các biến sau: +

+
    +
  • process_output: output
  • +
  • judge_output: đáp án
  • +
  • submission_source: Code bài nộp
  • +
  • judge_input: input
  • +
  • point_value: điểm của test đang chấm
  • +
  • case_position: thứ tự của test
  • +
  • submission_language: ngôn ngữ của bài nộp
  • +
  • execution_time: thời gian chạy
  • +
+

Return:

+
    +
  1. Cách 1: Trả về True/False
  2. +
  3. Cách 2: Trả về một object CheckerResult có thể được gọi như sau
    CheckerResult(case_passed_bool, points_awarded, feedback='')
  4. +
+ +

Ví dụ:

+

Dưới đây là ví dụ cho bài toán: Input gồm 1 số nguyên n. In ra 2 số nguyên a, b sao cho a + b = n. +

+
+from dmoj.result import CheckerResult
+
+
+def wa(feedback):
+    return CheckerResult(False, 0, feedback)
+
+
+def check(process_output, judge_output, judge_input, **kwargs):
+    # process the input
+    input_arr = judge_input.split()
+    assert(len(input_arr) == 1)
+    n = int(input_arr[0])
+
+    #  process the contestant's output
+    output_arr = process_output.split()
+
+    if (len(output_arr) != 2):
+        return wa('Wrong output format')
+
+    try:
+        a, b = int(output_arr[0]), int(output_arr[1])
+    except:
+        return wa('Wrong output format')
+
+    if (n == a + b):
+        return True
+    return wa('a + b != n')
+
+
+

2. Custom validator (CPP)

+
+

+ Để sử dụng chức năng này, cần viết một chương trình C++ pass vào 3 arguments theo thứ tự input_file, output_file, ans_file tương ứng với các file input, output, đáp án. +

+

+ Để test chương trình trên máy tính, có thể dùng lệnh như sau (Windows): +

+main.exe [input_file] [output_file] [ans_file]
+ hoặc thay bằng ./main trên Linux/MacOS. +

+

Return:

+

+ 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) +

+ +

Ví dụ:

+
+#include <bits/stdc++.h>
+using namespace std;
+
+int main(int argc, char** argv) {
+    ifstream inp(argv[1]);
+    ifstream out(argv[2]);
+    ifstream ans(argv[3]);
+
+    int n, a, b, c, d;
     
+    inp >> n;
+    out >> a >> b;
+    ans >> c >> d;
 
+    if (a + b == c + d) {
+        cout << a << " + " << b << " = " << c << " + " << d << endl;
+        return 0; // AC
+    }     
+    else {
+        cout << "a + b = " << a + b << " != " << n << endl;
+        return 1; // WA
+    }
+}
+        
+
{% endblock body %} \ No newline at end of file