game.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:icfpc2016-judge 作者: icfpc2016 项目源码 文件源码
def compile_problem(solution_spec):
    """Compiles a problem submission and generates a problem spec.

    Args:
        solution_spec: Specification string of a solution corresponding to the
            submitted problem.

    Returns:
        (problem_spec, problem_size)
        problem_spec: Specification string of the problem.
        problem_size: Problem size.

    Raises:
        VerificationError: If the solution specification is invalid.
        subprocess.TimeoutExpired: On judge timeout.
        AssertionError: On scrape error.
    """
    with make_temporary_file_with_content(solution_spec) as solution_file:
        proc = subprocess.Popen(
            ['./akatsuki', '--logtostderr', '--compile', solution_file.name],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        try:
            stdout_output, stderr_output = proc.communicate(
                timeout=_JUDGE_TIMEOUT_SECONDS)
        except subprocess.TimeoutExpired:
            proc.kill()
            proc.wait()
            raise  # report ISE
    if proc.returncode:
        m = _VERIFICATION_ERROR_RE.search(stdout_output)
        assert m, stdout_output  # report ISE
        raise VerificationError(m.group(1))
    problem_spec = stdout_output
    problem_size = sum(len(s) for s in problem_spec.split())
    return (problem_spec, problem_size)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号