Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Commit c833d6a

Browse files
committed
Added --detailed-checker option
1 parent 7ee9c15 commit c833d6a

File tree

5 files changed

+48
-20
lines changed

5 files changed

+48
-20
lines changed

python/args.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ def add_execution_group(parser: argparse.ArgumentParser):
146146
default=False)
147147

148148

149+
def add_ioi_group(parser: argparse.ArgumentParser):
150+
group = parser.add_argument_group("IOI options")
151+
group.add_argument(
152+
"--detailed-checker",
153+
help="Show the execution information also for the checker",
154+
action="store_true",
155+
default=False)
156+
157+
149158
def add_terry_group(parser: argparse.ArgumentParser):
150159
group = parser.add_argument_group("Terry options")
151160
group.add_argument(
@@ -171,6 +180,7 @@ def get_parser() -> argparse.ArgumentParser:
171180
add_generic_group(parser)
172181
add_remote_group(parser)
173182
add_execution_group(parser)
183+
add_ioi_group(parser)
174184
add_terry_group(parser)
175185

176186
parser.add_argument(

python/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def __init__(self, args):
3838
self.extra_time = args.extra_time # type: float
3939
self.copy_exe = args.copy_exe # type: # bool
4040

41+
# IOI group
42+
self.detailed_checker = args.detailed_checker
43+
4144
# terry group
4245
# self.arch = args.arch # type: Arch
4346
# self.seed = args.seed # type: int

python/formats/ioi_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def evaluate_task(frontend: Frontend, task: Task, solutions: List[Solution],
277277
curses_ui.stop()
278278

279279
if config.ui != UIS.SILENT:
280-
finish_ui = IOIFinishUI(task, ui_interface)
280+
finish_ui = IOIFinishUI(config, task, ui_interface)
281281
finish_ui.print()
282282
return ui_interface
283283

python/uis/ioi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(self):
5858
self.message = "Waiting..."
5959
self.checker_outcome = "Waiting..."
6060
self.checked = False
61+
self.checker_result = None # type: Result
6162

6263

6364
class SourceFileCompilationResult:
@@ -120,9 +121,6 @@ def __init__(self, source_file: SourceFile, task: Task,
120121
self.subtask_results = [SubtaskSolutionResult.WAITING] * len(subtasks)
121122
self.testcase_results = dict(
122123
) # type: Dict[int, Dict[int, TestcaseSolutionInfo]]
123-
self.st_remaining_cases = [
124-
len(subtask) for subtask in subtasks.values()
125-
]
126124

127125
for st_num, subtask in subtasks.items():
128126
self.testcase_results[st_num] = dict()
@@ -163,6 +161,7 @@ def update_default_check_result(self, subtask: int, testcase: int,
163161
# the default checker is used only in batch type tasks, no need for
164162
# communication's out-of-order callbacks
165163
testcase_status = self.testcase_results[subtask][testcase]
164+
testcase_status.checker_result = result
166165
testcase_status.checked = True
167166
if result.status == ResultStatus.SUCCESS:
168167
testcase_status.status = TestcaseSolutionStatus.ACCEPTED
@@ -187,6 +186,7 @@ def update_custom_check_result(self, subtask: int, testcase: int,
187186
# will end successfully. If else update_eval_result will overwrite the
188187
# result later
189188
testcase_status = self.testcase_results[subtask][testcase]
189+
testcase_status.checker_result = state.result
190190
# if the solution failed there is no need for the checker
191191
if testcase_status.checked:
192192
return

python/uis/ioi_finish_ui.py

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env python3
22
from typing import List
33

4-
from task_maker.formats import Task, TaskType
4+
from task_maker.config import Config
5+
from task_maker.formats import Task
56
from task_maker.printer import StdoutPrinter
67
from task_maker.task_maker_frontend import ResultStatus
78
from task_maker.uis import result_to_str
@@ -13,7 +14,8 @@
1314

1415

1516
class IOIFinishUI:
16-
def __init__(self, task: Task, interface: IOIUIInterface):
17+
def __init__(self, config: Config, task: Task, interface: IOIUIInterface):
18+
self.config = config
1719
self.task = task
1820
self.interface = interface
1921
self.printer = StdoutPrinter()
@@ -196,20 +198,18 @@ def _print_solution(self, solution: str):
196198
else:
197199
used_time = 0
198200
memory = 0
199-
self.printer.text(" [")
200-
if used_time >= LIMITS_MARGIN * self.task.time_limit:
201-
self.printer.yellow(
202-
"{:.3f}s".format(used_time), bold=False)
203-
else:
204-
self.printer.text("{:.3f}s".format(used_time))
205-
self.printer.text(" |")
206-
if memory >= LIMITS_MARGIN * self.task.memory_limit_kb / 1024:
207-
self.printer.yellow(
208-
"{:5.1f}MiB".format(memory), bold=False)
209-
else:
210-
self.printer.text("{:5.1f}MiB".format(memory))
211-
self.printer.text("] ")
212-
201+
self._print_exec_stat(used_time, memory, self.task.time_limit,
202+
self.task.memory_limit_kb, "")
203+
if self.config.detailed_checker and testcase.checker_result:
204+
check_time = testcase.checker_result.resources.cpu_time + \
205+
testcase.checker_result.resources.sys_time
206+
check_memory = testcase.checker_result.resources.memory
207+
self._print_exec_stat(check_time, check_memory / 1024,
208+
self.task.time_limit * 2,
209+
self.task.memory_limit_kb * 2,
210+
"checker")
211+
212+
self.printer.text(" ")
213213
self.printer.text(testcase.message)
214214
self.printer.right("[{}]".format(solution))
215215

@@ -221,3 +221,18 @@ def _print_score(self, score: float, max_score: float,
221221
self.printer.green("{:.2f} / {:.2f}".format(score, max_score))
222222
else:
223223
self.printer.yellow("{:.2f} / {:.2f}".format(score, max_score))
224+
225+
def _print_exec_stat(self, time, memory, time_limit, memory_limit, name):
226+
self.printer.text(" [")
227+
if name:
228+
self.printer.text(name + " ")
229+
if time >= LIMITS_MARGIN * time_limit:
230+
self.printer.yellow("{:.3f}s".format(time), bold=False)
231+
else:
232+
self.printer.text("{:.3f}s".format(time))
233+
self.printer.text(" |")
234+
if memory >= LIMITS_MARGIN * memory_limit / 1024:
235+
self.printer.yellow("{:5.1f}MiB".format(memory), bold=False)
236+
else:
237+
self.printer.text("{:5.1f}MiB".format(memory))
238+
self.printer.text("]")

0 commit comments

Comments
 (0)