Exemplo n.º 1
0
def print_testcase_solution_result(printer: Printer, loading: str,
                                   info: TestcaseSolutionInfo):
    """
    Print the letter relative to the status of solution
    """
    if info.status == TestcaseSolutionStatus.WAITING:
        printer.text(".")
    elif info.status == TestcaseSolutionStatus.SOLVING:
        printer.blue(loading)
    elif info.status == TestcaseSolutionStatus.SOLVED:
        printer.text("s")
    elif info.status == TestcaseSolutionStatus.CHECKING:
        printer.text(loading)
    elif info.status == TestcaseSolutionStatus.SKIPPED:
        printer.text("X")
    elif info.checked and info.status == TestcaseSolutionStatus.ACCEPTED:
        printer.green("A", bold=True)
    elif info.checked and info.status == TestcaseSolutionStatus.WRONG_ANSWER:
        printer.red("W", bold=True)
    elif info.checked and info.status == TestcaseSolutionStatus.PARTIAL:
        printer.yellow("P", bold=True)
    elif info.checked and info.status == TestcaseSolutionStatus.FAILED:
        for res in info.result:
            if res.status != ResultStatus.SUCCESS:
                result = res
                break
        else:
            result = None
        # marked as failed even if no solution failed --> the checker
        if result is None:
            printer.bold("I", bold=True)
        elif result.status == ResultStatus.SIGNAL:
            printer.red("R", bold=True)
        elif result.status == ResultStatus.RETURN_CODE:
            printer.red("R", bold=True)
        elif result.status == ResultStatus.TIME_LIMIT:
            printer.red("T", bold=True)
        elif result.status == ResultStatus.WALL_LIMIT:
            printer.red("T", bold=True)
        elif result.status == ResultStatus.MEMORY_LIMIT:
            printer.red("M", bold=True)
        elif result.status == ResultStatus.MISSING_FILES:
            printer.red("F", bold=True)
        elif result.status == ResultStatus.INTERNAL_ERROR:
            printer.bold("I", bold=True)
        else:
            raise ValueError(result)
    elif not info.checked:
        printer.blue(loading)
    else:
        raise ValueError("{} {}".format(info.checked, info.status))
Exemplo n.º 2
0
def print_solutions_result(printer: Printer, task: IOITask,
                           solutions: Dict[str, SolutionStatus],
                           max_sol_len: int, loading: str):
    """
    Print the matrix with the solutions' statuses
    """
    printer.text(" " * max_sol_len + " ")
    max_score = sum(st.max_score for st in task.subtasks.values())
    printer.bold("{:^5.0f}|".format(max_score))
    for subtask in task.subtasks.values():
        printer.bold("{:^5.0f}".format(subtask.max_score))
    printer.text("\n")

    for solution, status in solutions.items():
        print_solution_column(printer, solution, max_sol_len)
        if all([
                s == SubtaskSolutionResult.WAITING
                for s in status.subtask_results.values()
        ]):
            printer.text(" ... ")
        elif any([
                s == SubtaskSolutionResult.RUNNING
                for s in status.subtask_results.values()
        ]):
            printer.text("  {}  ".format(loading))
        else:
            printer.text(" {:^3.0f} ".format(status.score))
        printer.text("|")

        for st_num in status.subtask_results.keys():
            score = status.subtask_scores[st_num]
            result = status.subtask_results[st_num]
            if result == SubtaskSolutionResult.WAITING:
                printer.text(" ... ")
            elif result == SubtaskSolutionResult.RUNNING:
                printer.text("  {}  ".format(loading))
            else:
                print_subtask_result(printer, " {:^3.0f} ".format(score),
                                     result)

        printer.text("  ")
        for st_num in status.subtask_results.keys():
            testcases = status.testcase_results[st_num]
            st_result = status.subtask_results[st_num]
            print_subtask_result(printer, "[", st_result)
            for tc_num, testcase in testcases.items():
                print_testcase_solution_result(printer, loading, testcase)
            print_subtask_result(printer, "]", st_result)

        printer.text("\n")