This commit is contained in:
virusdefender 2016-10-26 23:11:29 +08:00
parent 85d6b38a7a
commit c85a19e010
20 changed files with 461 additions and 234 deletions

View File

@ -108,6 +108,12 @@
<li >
<a href="../testcase/">TestCase</a>
</li>
<li class="active">
<a href="./">Deploy</a>
</li>
@ -131,7 +137,7 @@
</a>
</li>
<li >
<a rel="next" href="../">
<a rel="next" href="../testcase/">
<i class="fa fa-arrow-left"></i> Previous
</a>
</li>

View File

@ -108,6 +108,12 @@
<li >
<a href="testcase/">TestCase</a>
</li>
<li >
<a href="deploy/">Deploy</a>
</li>
@ -136,7 +142,7 @@
</a>
</li>
<li >
<a rel="prev" href="deploy/">
<a rel="prev" href="testcase/">
Next <i class="fa fa-arrow-right"></i>
</a>
</li>

View File

@ -0,0 +1,284 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="../../../img/favicon.ico">
<title>TestCase - Online Judge Docs</title>
<link href="../../../css/bootstrap-custom.min.css" rel="stylesheet">
<link href="../../../css/font-awesome-4.0.3.css" rel="stylesheet">
<link rel="stylesheet" href="../../../css/highlight.css">
<link href="../../../css/base.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<!-- Collapsed navigation -->
<div class="navbar-header">
<!-- Expander button -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- Main title -->
<a class="navbar-brand" href="../../..">Online Judge Docs</a>
</div>
<!-- Expanded navigation -->
<div class="navbar-collapse collapse">
<!-- Main navigation -->
<ul class="nav navbar-nav">
<li >
<a href="../../..">Home</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Judger <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="../../../Judger/">index</a>
</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="">English</a>
<ul class="dropdown-menu">
<li >
<a href="../../../Judger/English/">API</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="dropdown active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">JudgeServer <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="../../">index</a>
</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="">English</a>
<ul class="dropdown-menu">
<li >
<a href="../">API</a>
</li>
<li class="active">
<a href="./">TestCase</a>
</li>
<li >
<a href="../deploy/">Deploy</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<!-- Search, Navigation and Repo links -->
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#" data-toggle="modal" data-target="#mkdocs_search_modal">
<i class="fa fa-search"></i> Search
</a>
</li>
<li >
<a rel="next" href="../">
<i class="fa fa-arrow-left"></i> Previous
</a>
</li>
<li >
<a rel="prev" href="../deploy/">
Next <i class="fa fa-arrow-right"></i>
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="col-md-3"><div class="bs-sidebar hidden-print affix well" role="complementary">
<ul class="nav bs-sidenav">
<li class="main active"><a href="#testcase-format">Testcase format</a></li>
<li><a href="#normal-problem">Normal problem</a></li>
<li><a href="#special-judge">Special Judge</a></li>
</ul>
</div></div>
<div class="col-md-9" role="main">
<h1 id="testcase-format">Testcase format</h1>
<p>Each testcase directory contains its testcase files, the conetent of input files will be redirected to stdin, and stdout of process will be compared with output files(normal problem) or judged by your special judge code(special judge).</p>
<p>Testcase meta data is in <code>info</code> file.</p>
<h2 id="normal-problem">Normal problem</h2>
<p>Both input and output files are required.</p>
<pre><code>root@JudgeServer:~/test_case/normal# tree
.
|-- 1.in
|-- 1.out
`-- info
0 directories, 3 files
root@JudgeServer:~/test_case/normal# cat 1.in
1 2
root@JudgeServer:~/test_case/normal# cat 1.out
3
</code></pre>
<p>Example of <code>info</code> file</p>
<ul>
<li>spj: for normal problem, it is <code>false</code></li>
<li>test_cases: <code>name</code> - <code>data</code> dict<ul>
<li>striped_output_md5: md5 of output file which trailing empty characters has been removed</li>
<li>input_name and output_name: name of input and output file</li>
<li>input_size and output_size: size of input and output file</li>
</ul>
</li>
</ul>
<pre><code class="js">{
&quot;spj&quot;: false,
&quot;test_cases&quot;: {
&quot;1&quot;: {
&quot;striped_output_md5&quot;: &quot;eccbc87e4b5ce2fe28308fd9f2a7baf3&quot;,
&quot;output_size&quot;: 2,
&quot;input_name&quot;: &quot;1.in&quot;,
&quot;input_size&quot;: 4,
&quot;output_name&quot;: &quot;1.out&quot;
}
}
}
</code></pre>
<h2 id="special-judge">Special Judge</h2>
<p>You only need input files.</p>
<pre><code>root@JudgeServer:~/test_case/spj# tree
.
|-- 1.in
`-- info
0 directories, 3 files
root@JudgeServer:~/test_case/normal# cat 1.in
1 2
</code></pre>
<p>Example of <code>info</code> file</p>
<ul>
<li>spj: for special judge problem, it is <code>true</code></li>
<li>test_cases: <code>name</code> - <code>data</code> dict<ul>
<li>input_name: name of input file</li>
<li>input_size: size of input file</li>
</ul>
</li>
</ul>
<pre><code class="js">{
&quot;spj&quot;: true,
&quot;test_cases&quot;: {
&quot;1&quot;: {
&quot;input_name&quot;: &quot;1.in&quot;,
&quot;input_size&quot;: 4
}
}
}
</code></pre></div>
</div>
<footer class="col-md-12">
<hr>
<center>Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.</center>
</footer>
<script src="../../../js/jquery-1.10.2.min.js"></script>
<script src="../../../js/bootstrap-3.0.3.min.js"></script>
<script src="../../../js/highlight.pack.js"></script>
<script>var base_url = '../../..';</script>
<script data-main="../../../mkdocs/js/search.js" src="../../../mkdocs/js/require.js"></script>
<script src="../../../js/base.js"></script>
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="dialog" aria-labelledby="Search Modal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="exampleModalLabel">Search</h4>
</div>
<div class="modal-body">
<p>
From here you can search these documents. Enter
your search terms below.
</p>
<form role="form">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search..." id="mkdocs-search-query">
</div>
</form>
<div id="mkdocs-search-results"></div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -108,6 +108,12 @@
<li >
<a href="English/testcase/">TestCase</a>
</li>
<li >
<a href="English/deploy/">Deploy</a>
</li>
@ -161,7 +167,8 @@
<ul>
<li>JudgeServer <ul>
<li>English <ul>
<li><a href="../JudgeServer/English/">API</a></li>
<li><a href="../JudgeServer/English/i">API</a></li>
<li><a href="../JudgeServer/English/testcase">TestCase</a></li>
<li><a href="../JudgeServer/English/deploy">Deploy</a></li>
</ul>
</li>

View File

@ -108,6 +108,12 @@
<li >
<a href="../../JudgeServer/English/testcase/">TestCase</a>
</li>
<li >
<a href="../../JudgeServer/English/deploy/">Deploy</a>
</li>

View File

@ -108,6 +108,12 @@
<li >
<a href="../JudgeServer/English/testcase/">TestCase</a>
</li>
<li >
<a href="../JudgeServer/English/deploy/">Deploy</a>
</li>
@ -161,7 +167,7 @@
<ul>
<li>Judger <ul>
<li>English <ul>
<li><a href="../Judger/English/">API</a></li>
<li><a href="../Judger/English/i">API</a></li>
</ul>
</li>
</ul>

View File

@ -108,6 +108,12 @@
<li >
<a href="JudgeServer/English/testcase/">TestCase</a>
</li>
<li >
<a href="JudgeServer/English/deploy/">Deploy</a>
</li>
@ -161,17 +167,18 @@
<p>目前此处的文档均为未公开发布版本的最新release的版本请参考github。</p>
<p>https://github.com/QingdaoU</p>
<ul>
<li><a href="./">Home</a></li>
<li><a href="./i">Home</a></li>
<li>Judger <ul>
<li>English <ul>
<li><a href="./Judger/English/">API</a></li>
<li><a href="./Judger/English/i">API</a></li>
</ul>
</li>
</ul>
</li>
<li>JudgeServer <ul>
<li>English <ul>
<li><a href="./JudgeServer/English/">API</a></li>
<li><a href="./JudgeServer/English/i">API</a></li>
<li><a href="./JudgeServer/English/testcase">TestCase</a></li>
<li><a href="./JudgeServer/English/deploy">Deploy</a></li>
</ul>
</li>

View File

@ -108,6 +108,12 @@
<li >
<a href="../../JudgeServer/English/testcase/">TestCase</a>
</li>
<li >
<a href="../../JudgeServer/English/deploy/">Deploy</a>
</li>

View File

@ -108,6 +108,12 @@
<li >
<a href="../JudgeServer/English/testcase/">TestCase</a>
</li>
<li >
<a href="../JudgeServer/English/deploy/">Deploy</a>
</li>
@ -161,7 +167,7 @@
<ul>
<li>Judger <ul>
<li>English <ul>
<li><a href="../Judger/English/">API</a></li>
<li><a href="../Judger/English/i">API</a></li>
</ul>
</li>
</ul>

View File

@ -2,12 +2,12 @@
"docs": [
{
"location": "/",
"text": "Welcome to Online Judge\n\n\n\u76ee\u524d\u6b64\u5904\u7684\u6587\u6863\u5747\u4e3a\u672a\u516c\u5f00\u53d1\u5e03\u7248\u672c\u7684\uff0c\u6700\u65b0release\u7684\u7248\u672c\u8bf7\u53c2\u8003github\u3002\n\n\nhttps://github.com/QingdaoU\n\n\n\n\nHome\n\n\nJudger \n\n\nEnglish \n\n\nAPI\n\n\n\n\n\n\n\n\n\n\nJudgeServer \n\n\nEnglish \n\n\nAPI\n\n\nDeploy",
"text": "Welcome to Online Judge\n\n\n\u76ee\u524d\u6b64\u5904\u7684\u6587\u6863\u5747\u4e3a\u672a\u516c\u5f00\u53d1\u5e03\u7248\u672c\u7684\uff0c\u6700\u65b0release\u7684\u7248\u672c\u8bf7\u53c2\u8003github\u3002\n\n\nhttps://github.com/QingdaoU\n\n\n\n\nHome\n\n\nJudger \n\n\nEnglish \n\n\nAPI\n\n\n\n\n\n\n\n\n\n\nJudgeServer \n\n\nEnglish \n\n\nAPI\n\n\nTestCase\n\n\nDeploy",
"title": "Home"
},
{
"location": "/#welcome-to-online-judge",
"text": "\u76ee\u524d\u6b64\u5904\u7684\u6587\u6863\u5747\u4e3a\u672a\u516c\u5f00\u53d1\u5e03\u7248\u672c\u7684\uff0c\u6700\u65b0release\u7684\u7248\u672c\u8bf7\u53c2\u8003github\u3002 https://github.com/QingdaoU Home Judger English API JudgeServer English API Deploy",
"text": "\u76ee\u524d\u6b64\u5904\u7684\u6587\u6863\u5747\u4e3a\u672a\u516c\u5f00\u53d1\u5e03\u7248\u672c\u7684\uff0c\u6700\u65b0release\u7684\u7248\u672c\u8bf7\u53c2\u8003github\u3002 https://github.com/QingdaoU Home Judger English API JudgeServer English API TestCase Deploy",
"title": "Welcome to Online Judge"
},
{
@ -87,12 +87,12 @@
},
{
"location": "/JudgeServer/",
"text": "Table of contents\n\n\n\n\nJudgeServer \n\n\nEnglish \n\n\nAPI\n\n\nDeploy",
"text": "Table of contents\n\n\n\n\nJudgeServer \n\n\nEnglish \n\n\nAPI\n\n\nTestCase\n\n\nDeploy",
"title": "index"
},
{
"location": "/JudgeServer/#table-of-contents",
"text": "JudgeServer English API Deploy",
"text": "JudgeServer English API TestCase Deploy",
"title": "Table of contents"
},
{
@ -180,6 +180,26 @@
"text": "SUCCESS = 0 INVALID_CONFIG = -1 CLONE_FAILED = -2 PTHREAD_FAILED = -3 WAIT_FAILED = -4 ROOT_REQUIRED = -5 LOAD_SECCOMP_FAILED = -6 SETRLIMIT_FAILED = -7 DUP2_FAILED = -8 SETUID_FAILED = -9 EXECVE_FAILED = -10 SPJ_ERROR = -11",
"title": "error field return value"
},
{
"location": "/JudgeServer/English/testcase/",
"text": "Testcase format\n\n\nEach testcase directory contains its testcase files, the conetent of input files will be redirected to stdin, and stdout of process will be compared with output files(normal problem) or judged by your special judge code(special judge).\n\n\nTestcase meta data is in \ninfo\n file.\n\n\nNormal problem\n\n\nBoth input and output files are required.\n\n\nroot@JudgeServer:~/test_case/normal# tree\n.\n|-- 1.in\n|-- 1.out\n`-- info\n\n0 directories, 3 files\nroot@JudgeServer:~/test_case/normal# cat 1.in\n1 2\nroot@JudgeServer:~/test_case/normal# cat 1.out\n3\n\n\n\n\nExample of \ninfo\n file\n\n\n\n\nspj: for normal problem, it is \nfalse\n\n\ntest_cases: \nname\n - \ndata\n dict\n\n\nstriped_output_md5: md5 of output file which trailing empty characters has been removed\n\n\ninput_name and output_name: name of input and output file\n\n\ninput_size and output_size: size of input and output file\n\n\n\n\n\n\n\n\n{\n \nspj\n: false,\n \ntest_cases\n: {\n \n1\n: {\n \nstriped_output_md5\n: \neccbc87e4b5ce2fe28308fd9f2a7baf3\n,\n \noutput_size\n: 2,\n \ninput_name\n: \n1.in\n,\n \ninput_size\n: 4,\n \noutput_name\n: \n1.out\n\n }\n }\n}\n\n\n\n\n\nSpecial Judge\n\n\nYou only need input files.\n\n\nroot@JudgeServer:~/test_case/spj# tree\n.\n|-- 1.in\n`-- info\n\n0 directories, 3 files\nroot@JudgeServer:~/test_case/normal# cat 1.in\n1 2\n\n\n\n\nExample of \ninfo\n file\n\n\n\n\nspj: for special judge problem, it is \ntrue\n\n\ntest_cases: \nname\n - \ndata\n dict\n\n\ninput_name: name of input file\n\n\ninput_size: size of input file\n\n\n\n\n\n\n\n\n{\n \nspj\n: true,\n \ntest_cases\n: {\n \n1\n: {\n \ninput_name\n: \n1.in\n,\n \ninput_size\n: 4\n }\n }\n}",
"title": "TestCase"
},
{
"location": "/JudgeServer/English/testcase/#testcase-format",
"text": "Each testcase directory contains its testcase files, the conetent of input files will be redirected to stdin, and stdout of process will be compared with output files(normal problem) or judged by your special judge code(special judge). Testcase meta data is in info file.",
"title": "Testcase format"
},
{
"location": "/JudgeServer/English/testcase/#normal-problem",
"text": "Both input and output files are required. root@JudgeServer:~/test_case/normal# tree\n.\n|-- 1.in\n|-- 1.out\n`-- info\n\n0 directories, 3 files\nroot@JudgeServer:~/test_case/normal# cat 1.in\n1 2\nroot@JudgeServer:~/test_case/normal# cat 1.out\n3 Example of info file spj: for normal problem, it is false test_cases: name - data dict striped_output_md5: md5 of output file which trailing empty characters has been removed input_name and output_name: name of input and output file input_size and output_size: size of input and output file {\n spj : false,\n test_cases : {\n 1 : {\n striped_output_md5 : eccbc87e4b5ce2fe28308fd9f2a7baf3 ,\n output_size : 2,\n input_name : 1.in ,\n input_size : 4,\n output_name : 1.out \n }\n }\n}",
"title": "Normal problem"
},
{
"location": "/JudgeServer/English/testcase/#special-judge",
"text": "You only need input files. root@JudgeServer:~/test_case/spj# tree\n.\n|-- 1.in\n`-- info\n\n0 directories, 3 files\nroot@JudgeServer:~/test_case/normal# cat 1.in\n1 2 Example of info file spj: for special judge problem, it is true test_cases: name - data dict input_name: name of input file input_size: size of input file {\n spj : true,\n test_cases : {\n 1 : {\n input_name : 1.in ,\n input_size : 4\n }\n }\n}",
"title": "Special Judge"
},
{
"location": "/JudgeServer/English/deploy/",
"text": "Deploy\n\n\nReuqirements:\n\n\n\n\ndocker \n= 1.12\n\n\ndocker-compose \n= 1.8\n\n\n\n\nThree environment variables below must be set manully in \ndocker-compose.yml\n\n\n\n\nservice_discovery_url\n\n\njudger_token\n\n\nservice_url\n\n\n\n\njudge_server\n will send heartbeat request to \nservice_discovery_url\n every five seconds.\n\n\nservice_url\n is used to tell server to send task to this url(\njudge_server\n).\n\n\nExample of \ndocker-compose.yml\n\n\nversion: \n2\n\nservices:\n judge_server:\n image: judge_server\n cpu_quota: 90000\n read_only: true\n cap_drop:\n - SETPCAP\n - MKNOD\n - NET_BIND_SERVICE\n - SYS_CHROOT\n - SETFCAP\n - FSETID\n tmpfs:\n - /tmp\n - /judger_run:exec,mode=777\n - /spj:exec,mode=777\n volumes:\n - /data/JudgeServer/tests/test_case:/test_case:ro\n - /data/log:/log\n - /data/JudgeServer:/code:ro\n environment:\n - judger_token=token\n - service_discovery_url=https://virusdefender.net/service.php\n - service_url=http://1.2.3.4:12358\n ports:\n - \n0.0.0.0:12358:8080\n\n\n\n\n\nHeartbeat request\n\n\n\n\nMethod\n: \nPOST\n\n\nX-JUDGE-SERVER-TOKEN\n: \nsha256(token)\n\n\nContent-Type\n: \napplication/json\n\n\n\n\nRequest data\n\n\n {\n \njudger_version\n: \n2.0.1\n,\n \nhostname\n: \nc45acd557074\n,\n \nrunning_task_number\n: 2,\n \ncpu_core\n: 1,\n \nmemory\n: 30.3,\n \naction\n: \nheartbeat\n,\n \ncpu\n: 0,\n \nservice_url\n: null or \nhttp://1.2.3.4:8005\n\n}\n\n\n\n\nIf everything is OK, you should give a JSON response as follows\n\n\n{\n \ndata\n: \nsuccess\n,\n \nerr\n: null\n}",

View File

@ -4,7 +4,7 @@
<url>
<loc>None/</loc>
<lastmod>2016-10-22</lastmod>
<lastmod>2016-10-26</lastmod>
<changefreq>daily</changefreq>
</url>
@ -13,7 +13,7 @@
<url>
<loc>None/Judger/</loc>
<lastmod>2016-10-22</lastmod>
<lastmod>2016-10-26</lastmod>
<changefreq>daily</changefreq>
</url>
@ -29,7 +29,7 @@
<url>
<loc>None/JudgeServer/</loc>
<lastmod>2016-10-22</lastmod>
<lastmod>2016-10-26</lastmod>
<changefreq>daily</changefreq>
</url>

8
gen.py
View File

@ -9,11 +9,15 @@ with open("mkdocs_template.yml", "r") as f:
def one(item, depth=0, result=""):
for k, v in item.iteritems():
if isinstance(v, basestring):
result += " ".join([" " * depth, "-", "[" + k + "](/" + v.rstrip("index.md").rstrip(".md") + ")\n"])
if v.endswith("index.md"):
v = v[:-7]
if v.endswith(".md"):
v = v[:-3]
result += " ".join([" " * depth, "-", "[" + k + "](/" + v + ")\n"])
elif isinstance(v, list):
result += " ".join([" " * depth, "-", k, "\n"])
for v_item in v:
result += one(v_item, depth+4)
result += one(v_item, depth + 4)
return result

View File

@ -6,10 +6,8 @@ pages:
- JudgeServer:
- English:
- API: JudgeServer/English/index.md
- TestCase: JudgeServer/English/testcase.md
- Deploy: JudgeServer/English/deploy.md
# - 中文:
# - API: JudgeServer/Chinese/index.md
# - 部署: JudgeServer/Chinese/deploy.md
docs_dir: src
site_dir: docs
site_name: Online Judge Docs

View File

@ -1,21 +0,0 @@
# 同主机link场景
oj_web_server和judge_server在同一台服务器上而且judge_server中link oj_web_server。
oj_web_server需要设置环境变量`judger_token`,这样`judge_server`就可以在`OJ_WEB_SERVER_ENV_judger_token`环境变量中得到token`OJ_WEB_SERVER_PORT_8080_TCP_ADDR`得到ip`OJ_WEB_SERVER_PORT_8080_TCP_PORT`得到端口从而每5秒向该ip发送心跳包在HTTP头中携带了`X-JUDGE-SERVER-TOKEN`值为token的sha256。
# 跨主机场景
如果不在同一台服务器上需要手动设置judge_server的下面四个环境变量
- `service_discovery_url`
- `judger_token`
通过以上两个环境变量这样就可以向该url发送心跳包了
- `service_host`
- `service_port`
因为跨主机的情况下oj_web_server是无法得知judge_server的ip和端口的需要主动的设置然后在心跳包中会带上这两个信息让oj_web_server能够主动访问。此时judge_server只能使用固定端口映射。

View File

@ -1,190 +0,0 @@
# JudgeServer API
所有的请求请在HTTP头中放入`X-Judge-Server-Token`字段值为token的sha256结果。
所有的响应都是两个字段,`err``data`,正常情况下`err``null``data`为响应的数据。出现错误的情况下,`err`是错误代码,`data`为错误详情。下面所有的响应都是`data`的内容。
# 获取系统状态
- URL `/ping`
- Method `POST`
## 参数
- 无参数
## 响应
```js
{
"judger_version": "2.0.1",
"hostname": "d3765528134e",
// cpu核数这个数字也确定了可以并发运行的判题任务数量
"cpu_core": 1,
// cpu和内存使用率百分比
"cpu": 4.1,
"memory": 24.5,
"action": "pong"
}
```
# 判题非Special Judge)
- URL `/judge`
- Method `POST`
## 参数
- src源码
- language_config参考`languages.py`中,一般不需要修改
- max_cpu_time单位毫秒
- max_memory最大内存单位字节
- test_case_id用于找到存放有测试用例的文件夹
## 响应
```js
[
// 每组都是一个测试用例通过test_case字段区分
{
// cpu时间毫秒
"cpu_time": 1,
// 见本文档最后部分
"result": 0,
// 内存,字节
"memory": 12836864,
// 实际时间,毫秒
"real_time": 2,
"signal": 0,
"error": 0,
"exit_code": 0,
"output_md5": "eccbc87e4b5ce2fe28308fd9f2a7baf3",
// 测试用例id
"test_case": 1
},
{
"cpu_time": 1,
"result": 0,
"memory": 12849152,
"real_time": 1,
"signal": 0,
"error": 0,
"exit_code": 0,
"output_md5": "eccbc87e4b5ce2fe28308fd9f2a7baf3",
"test_case": 2
}
]
```
在编译错误的时候,返回
```js
{
"err": "CompileError",
"data": "编译器的错误输出"
}
```
# 编译Special Judge
- URL `/compile_spj`
- Method `POST`
## 参数
- src源码
- spj_versionSpecial Judge的版本用于决定是否要重新编译二进制
- spj_compile_config参考`languages.py`,一般不需要修改
- test_case_id
## 响应
```js
"success"
```
在编译错误的时候,返回
```js
{
"err": "SPJCompileError",
"data": "编译器的错误输出"
}
```
# 判题Special Judge)
注意必须提前编译Special Judge见上一个API
- URL `/judge`
- Method `POST`
## 参数
- src
- language_config
- max_cpu_time
- max_memory
- test_case_id
- spj_version
- spj_config参考`languages.py`,一般不需要修改
## 响应
```js
[
// 每组都是一个测试用例通过test_case字段区分
{
// cpu时间毫秒
"cpu_time": 1,
// 见本文档最后部分
"result": 0,
// 内存,字节
"memory": 12836864,
// 实际时间,毫秒
"real_time": 2,
"signal": 0,
"error": 0,
"exit_code": 0,
"output_md5": null,
// 测试用例id
"test_case": 1
},
{
"cpu_time": 1,
"result": 0,
"memory": 12849152,
"real_time": 1,
"signal": 0,
"error": 0,
"exit_code": 0,
"output_md5": null,
"test_case": 2
}
]
```
在编译错误的时候,返回
```js
{
"err": "CompileError",
"data": "编译器的错误输出"
}
```
# result 字段含义
- WRONG_ANSWER = -1
- AEECPTED = 0
- CPU_TIME_LIMITED = 1
- REAL_TIME_LIMIT_EXCEEDED = 2
- MEMORY_LIMIT_EXCEEDED = 3
- RUNTIME_ERROR = 4
- SYSTEM_ERROR = 5

View File

View File

@ -0,0 +1,81 @@
# Testcase format
Each testcase directory contains its testcase files, the conetent of input files will be redirected to stdin, and stdout of process will be compared with output files(normal problem) or judged by your special judge code(special judge).
Testcase meta data is in `info` file.
## Normal problem
Both input and output files are required.
```
root@JudgeServer:~/test_case/normal# tree
.
|-- 1.in
|-- 1.out
`-- info
0 directories, 3 files
root@JudgeServer:~/test_case/normal# cat 1.in
1 2
root@JudgeServer:~/test_case/normal# cat 1.out
3
```
Example of `info` file
- spj: for normal problem, it is `false`
- test_cases: `name` - `data` dict
- striped_output_md5: md5 of output file which trailing empty characters has been removed
- input_name and output_name: name of input and output file
- input_size and output_size: size of input and output file
```js
{
"spj": false,
"test_cases": {
"1": {
"striped_output_md5": "eccbc87e4b5ce2fe28308fd9f2a7baf3",
"output_size": 2,
"input_name": "1.in",
"input_size": 4,
"output_name": "1.out"
}
}
}
```
## Special Judge
You only need input files.
```
root@JudgeServer:~/test_case/spj# tree
.
|-- 1.in
`-- info
0 directories, 3 files
root@JudgeServer:~/test_case/normal# cat 1.in
1 2
```
Example of `info` file
- spj: for special judge problem, it is `true`
- test_cases: `name` - `data` dict
- input_name: name of input file
- input_size: size of input file
```js
{
"spj": true,
"test_cases": {
"1": {
"input_name": "1.in",
"input_size": 4
}
}
}
```

View File

@ -1,5 +1,6 @@
# Table of contents
- JudgeServer
- English
- [API](/JudgeServer/English/)
- [API](/JudgeServer/English/i)
- [TestCase](/JudgeServer/English/testcase)
- [Deploy](/JudgeServer/English/deploy)

View File

@ -1,4 +1,4 @@
# Table of contents
- Judger
- English
- [API](/Judger/English/)
- [API](/Judger/English/i)

View File

@ -1,4 +1,4 @@
# Table of contents
- Judger
- English
- [API](/Judger/English/)
- [API](/Judger/English/i)