-
Notifications
You must be signed in to change notification settings - Fork 0
/
judge_main.py
54 lines (52 loc) · 1.94 KB
/
judge_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
# coding=utf-8
def judge(solution_id, problem_id, data_count, time_limit,
mem_limit, program_info, result_code, language):
low_level()
'''评测编译类型语言'''
max_mem = 0
max_time = 0
if language in ["java", 'python2', 'python3', 'ruby', 'perl']:
time_limit = time_limit * 2
mem_limit = mem_limit * 2
for i in range(data_count):
ret = judge_one_mem_time(
solution_id,
problem_id,
i + 1,
time_limit + 10,
mem_limit,
language)
if ret == False:
continue
if ret['result'] == 5:
program_info['result'] = result_code["Runtime Error"]
return program_info
elif ret['result'] == 2:
program_info['result'] = result_code["Time Limit Exceeded"]
program_info['take_time'] = time_limit + 10
return program_info
elif ret['result'] == 3:
program_info['result'] = result_code["Memory Limit Exceeded"]
program_info['take_memory'] = mem_limit
return program_info
if max_time < ret["timeused"]:
max_time = ret['timeused']
if max_mem < ret['memoryused']:
max_mem = ret['memoryused']
result = judge_result(problem_id, solution_id, i + 1)
if result == False:
continue
if result == "Wrong Answer" or result == "Output limit":
program_info['result'] = result_code[result]
break
elif result == 'Presentation Error':
program_info['result'] = result_code[result]
elif result == 'Accepted':
if program_info['result'] != 'Presentation Error':
program_info['result'] = result_code[result]
else:
logging.error("judge did not get result")
program_info['take_time'] = max_time
program_info['take_memory'] = max_mem
return program_info