修复cpp引用bits/stdc++时的编译问题,

支持公开比赛题目
This commit is contained in:
zema1 2017-11-02 21:37:47 +08:00
parent 70f52b6f27
commit cec27407e1
3 changed files with 32 additions and 5 deletions

View File

@ -23,7 +23,7 @@ int main() {
"exe_name": "main",
"max_cpu_time": 3000,
"max_real_time": 5000,
"max_memory": 128 * 1024 * 1024,
"max_memory": 256 * 1024 * 1024,
"compile_command": "/usr/bin/gcc -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c99 {src_path} -lm -o {exe_path}",
},
"run": {
@ -59,7 +59,7 @@ _cpp_lang_config = {
"exe_name": "main",
"max_cpu_time": 3000,
"max_real_time": 5000,
"max_memory": 128 * 1024 * 1024,
"max_memory": 256 * 1024 * 1024,
"compile_command": "/usr/bin/g++ -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c++11 {src_path} -lm -o {exe_path}",
},
"run": {
@ -100,7 +100,7 @@ _java_lang_config = {
},
"run": {
"command": "/usr/bin/java -cp {exe_dir} -Xss1M -Xms16M -Xmx{max_memory}k "
"-Djava.security.manager -Djava.security.policy==/etc/java_policy -Djava.awt.headless=true Main",
"-Djava.security.manager -Djava.security.policy=/etc/java_policy -Djava.awt.headless=true Main",
"seccomp_rule": None,
"env": ["MALLOC_ARENA_MAX=1"]
}

View File

@ -1,9 +1,10 @@
from django.conf.urls import url
from ..views.admin import ContestProblemAPI, ProblemAPI, TestCaseUploadAPI
from ..views.admin import ContestProblemAPI, ProblemAPI, TestCaseUploadAPI, MakeContestProblemPublicAPIView
urlpatterns = [
url(r"^test_case/upload/?$", TestCaseUploadAPI.as_view(), name="test_case_upload_api"),
url(r"^problem/?$", ProblemAPI.as_view(), name="problem_admin_api"),
url(r"^contest/problem/?$", ContestProblemAPI.as_view(), name="contest_problem_admin_api"),
url(r"^contest_problem/make_public/?$", MakeContestProblemPublicAPIView.as_view(), name="make_public_api"),
]

View File

@ -305,7 +305,7 @@ class ContestProblemAPI(ProblemBase):
user = request.user
try:
problem = Problem.objects.get(id=problem_id, contest=contest)
problem = Problem.objects.get(id=problem_id)
if not user.can_mgmt_all_problem() and problem.created_by != user:
return self.error("Problem does not exist")
except Problem.DoesNotExist:
@ -336,3 +336,29 @@ class ContestProblemAPI(ProblemBase):
tag = ProblemTag.objects.create(name=tag)
problem.tags.add(tag)
return self.success()
class MakeContestProblemPublicAPIView(APIView):
@problem_permission_required
def post(self, request):
problem_id = request.data.get("problem_id")
if not problem_id:
return self.error("problem_id is required")
try:
problem = Problem.objects.get(id=problem_id)
except Problem.DoesNotExist:
return self.error("Problem does not exist")
if not problem.contest or problem.is_public:
return self.error("Alreay be a public problem")
problem.is_public = True
problem.save()
# https://docs.djangoproject.com/en/1.11/topics/db/queries/#copying-model-instances
tags = problem.tags.all()
problem.pk = None
problem.contest = None
problem.submission_number = problem.accepted_number = 0
problem.statistic_info = {}
problem.save()
problem.tags.set(tags)
return self.success()