|
|
@@ -28,9 +28,13 @@ def judge():
|
|
|
language = data['language']
|
|
|
time_limit = int(data['timeLimit'])
|
|
|
memory_limit = int(data['memoryLimit'])
|
|
|
- input_output_map = data['inputOutputMapping']
|
|
|
- td_total = len(input_output_map)
|
|
|
- save_test_cases(input_output_map, td_total)
|
|
|
+ input_list = data['inputList']
|
|
|
+ output_list = data['outputList']
|
|
|
+ if len(input_list)!=len(output_list):
|
|
|
+ return {'result': "System Error",
|
|
|
+ 'message': 'test data incompleted'}
|
|
|
+ td_total = len(input_list)
|
|
|
+ save_test_cases(input_list, output_list, td_total)
|
|
|
src_file = save_code(language, code)
|
|
|
rst = judge.judge(src_file, 'testcases', td_total, time_limit, memory_limit, language)
|
|
|
os.remove(src_file)
|
|
|
@@ -38,13 +42,15 @@ def judge():
|
|
|
return rst
|
|
|
|
|
|
|
|
|
-def save_test_cases(input_output_map, td_total):
|
|
|
+def save_test_cases(input_list,output_list, td_total):
|
|
|
+ if os.path.exists('testcases'):
|
|
|
+ shutil.rmtree('testcases')
|
|
|
os.mkdir('testcases')
|
|
|
for i in range(1, td_total + 1):
|
|
|
in_file = open('testcases/' + str(i) + '.in', 'w')
|
|
|
- in_file.write(input_output_map.keys[i - 1])
|
|
|
+ in_file.write(input_list[i - 1])
|
|
|
out_file = open('testcases/' + str(i) + '.out', 'w')
|
|
|
- out_file.write(input_output_map.values[i - 1])
|
|
|
+ out_file.write(output_list[i - 1])
|
|
|
|
|
|
|
|
|
def save_code(language, code):
|