Skip to content

Commit

Permalink
fix import checker
Browse files Browse the repository at this point in the history
  • Loading branch information
leduythuccs committed Dec 9, 2024
1 parent 7493a32 commit d888a77
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions judge/management/commands/create_icpc_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@ def update_problem_testcases(problem, testcases, test_file_path, checker_path, p
problem_data.custom_checker.save('checker.cpp', File(checker))
problem_data.checker_args = json.dumps({
"files": "checker.cpp",
"lang": "CPP17",
"lang": "CPP20",
"type": "testlib"
})
elif problem_type == INTERACTIVE:
problem_data.interactive = True
problem_data.grader = 'interactive'
problem_data.custom_grader.save('checker.cpp', File(checker))

if float_checker != 0:
problem_data.checker = 'floatsabs'
if float_checker is not None:
problem_data.checker = float_checker[0]
problem_data.checker_args = json.dumps({
"precision": float_checker,
"precision": float_checker[1],
})
except Exception:
problem_data = ProblemData(
Expand All @@ -130,7 +130,7 @@ def update_problem_testcases(problem, testcases, test_file_path, checker_path, p
problem_data.custom_checker.save('checker.cpp', File(checker))
problem_data.checker_args = json.dumps({
"files": "checker.cpp",
"lang": "CPP17",
"lang": "CPP20",
"type": "testlib"
})
elif problem_type == INTERACTIVE:
Expand Down Expand Up @@ -192,6 +192,7 @@ def create_problem(problem_name, icpc_folder):
else:
print(f'Skipped create problem {problem_name}.')
problem = Problem.objects.get(code=problem_code)
problem.name = get_problem_full_name(problem_folder) or problem_name

# pdf_path = os.path.join(problem_folder, f'{problem_name}.pdf')
# with open(pdf_path, 'rb') as f:
Expand All @@ -218,12 +219,23 @@ def create_problem(problem_name, icpc_folder):
# small hack to make the `open with` work without any modification
checker_path = os.path.join(problem_folder, 'problem.yaml')

float_checker = 0
float_checker = None
if problem_setting.get('validator_flags', None):
flags = problem_setting['validator_flags'].split(' ')
if len(flags) != 2 and flags[0] != 'float_tolerance':
if len(flags) != 2:
raise CommandError(f'Unsupported validator flags: {flags}')
if flags[0] == 'float_tolerance':
flags[0] = 'floats'
elif flags[0] == 'float_relative_tolerance':
flags[0] = 'floatsrel'
elif flags[0] == 'float_absolute_tolerance':
flags[0] = 'floatsabs'
else:
raise CommandError(f'Unsupported validator flags: {flags}')
float_checker = int(flags[1].split('-')[-1])
if not flags[1].startswith('1e-'):
raise CommandError(f'Unsupported validator flags: {flags}')

float_checker = (flags[0], int(flags[1][3:]))

if float_checker and problem_type != NORMAL:
raise CommandError('Float checker only support normal problem type')
Expand Down Expand Up @@ -260,7 +272,7 @@ def handle(self, *args, **options):

os.system(f'cd {icpc_folder} && git pull')

blacklist = ['xx-mien-nam', 'yy-mien-nam', '6-mien-trung', 'inversland']
blacklist = ['xx-mien-nam', 'yy-mien-nam', '6-mien-trung']
problems = [
name for name in os.listdir(icpc_folder)
if os.path.isdir(os.path.join(icpc_folder, name)) and
Expand All @@ -277,8 +289,8 @@ def handle(self, *args, **options):
msg = ' [custom checker]'
elif problem_type == INTERACTIVE:
msg = ' [interactive]'
if float_checker > 0:
msg = f' [float checker, precisions: {float_checker}]'
if float_checker is not None:
msg = f' [float checker {float_checker[0]}, precisions: {float_checker[1]}]'

messages[problem] = f'{n_sample} samples, {n_secret} secrets{msg}.'
print('Succeed.')
Expand Down

0 comments on commit d888a77

Please sign in to comment.