Skip to content

Commit 1194c9d

Browse files
authored
Merge pull request #99 from tossy310/domjudge-reactive-submit
Support packing DOMjudge reactive judge
2 parents c6882ad + 45a2b7b commit 1194c9d

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

rime/plugins/judge_system/domjudge.py

+29-6
Original file line numberDiff line numberDiff line change
@@ -297,24 +297,44 @@ def Pack(self, ui, testset):
297297
ui.errors.Exception(testset)
298298
yield False
299299

300-
if len(testset.judges) > 1:
300+
has_reactive = False
301+
has_custom_judge = False
302+
303+
if testset.reactives:
304+
if len(testset.reactives) != 1:
305+
ui.errors.Error(
306+
testset,
307+
'Multiple reactive runners is not supported in DOMJudge.')
308+
yield False
309+
if not isinstance(testset.reactives[0].variant,
310+
DOMJudgeReactiveRunner):
311+
ui.errors.Error(
312+
testset, 'Only domjudge_reactive_runner is supported.')
313+
yield False
314+
has_reactive = True
315+
elif len(testset.judges) > 1:
301316
ui.errors.Error(
302317
testset, 'Multiple varidators is not supported in DOMJudge.')
303318
yield False
304319
elif (len(testset.judges) == 1 and
305320
not isinstance(testset.judges[0], basic_codes.InternalDiffCode
306321
)):
307-
judge = testset.judges[0]
308-
309-
# TODO(tossy310): support DOMJudgeReactiveRunner
310-
if not isinstance(judge.variant, DOMJudgeJudgeRunner):
322+
if not isinstance(testset.judges[0].variant, DOMJudgeJudgeRunner):
311323
ui.errors.Error(
312324
testset,
313325
'Only domjudge_judge_runner is supported.')
314326
yield False
327+
has_custom_judge = True
328+
329+
if has_reactive or has_custom_judge:
330+
if has_reactive:
331+
judge = testset.reactives[0]
332+
elif has_custom_judge:
333+
judge = testset.judges[0]
315334

316335
validator_dir = os.path.join(
317336
pack_files_dir, 'output_validators',
337+
testset.problem.name + '_' +
318338
os.path.splitext(judge.src_name)[0])
319339
files.MakeDir(validator_dir)
320340
ui.console.PrintAction(
@@ -334,7 +354,10 @@ def Pack(self, ui, testset):
334354
# TODO: add more data to problem.yaml?
335355
yaml_file = os.path.join(pack_files_dir, 'problem.yaml')
336356
with open(yaml_file, 'w') as f:
337-
f.write('validation: custom\n')
357+
if has_custom_judge:
358+
f.write('validation: custom\n')
359+
elif has_reactive:
360+
f.write('validation: custom interactive\n')
338361

339362
if (testset.problem.domjudge_config_defined and
340363
testset.problem.domjudge_problem_file):

0 commit comments

Comments
 (0)