Created
October 22, 2013 06:16
-
-
Save chiro/7095944 to your computer and use it in GitHub Desktop.
Rime -> AtCoder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys, os, shutil | |
from os.path import * | |
command = "build" | |
dir_names = ["task", "in", "out", "sol", "etc"] | |
output_dir = join(abspath("./"), "atcoder", "Tasks") | |
if (exists(output_dir) == False): | |
os.system('mkdir -p %s' % output_dir) | |
# list of (problem_name, reference_solution, title) | |
problem_list = [("kyoto", "ref", "Problem Title")] | |
index = open(join(output_dir, "index.txt"), 'w') | |
for name, _, title in problem_list: | |
index.write("%s,%s\n" % (name, title)) | |
def output(problem_name, ref_sol): | |
os.system('./rime.py %s %s' % (command, problem_name)) | |
base_dir = abspath("./") | |
problem_dir = join(base_dir, problem_name) | |
new_dir = join(output_dir, problem_name) | |
# Remove existing output. | |
if (exists(new_dir)): | |
shutil.rmtree(new_dir) | |
os.mkdir(new_dir) | |
directories = {} | |
for name in dir_names: | |
directories[name] = join(new_dir, name) | |
os.mkdir(directories[name]) | |
# write score.txt | |
score = open(join(directories["etc"], "score.txt"), 'w') | |
score.write("All(100): *\n") | |
score.close() | |
# copy I/Os | |
tests_dir = join(problem_dir, "rime-out", "tests") | |
for f in os.listdir(tests_dir): | |
name, ext = splitext(f) | |
if (ext == ".in"): | |
shutil.copy(join(tests_dir, f), join(directories["in"], name + ".txt")) | |
elif (ext == ".diff"): | |
shutil.copy(join(tests_dir, f), join(directories["out"], name + ".txt")) | |
# copy the problem statement | |
for f in os.listdir(problem_dir): | |
name, ext = splitext(f) | |
if (ext == ".html"): | |
shutil.copy(join(problem_dir, f), | |
join(directories["task"], "statement.html")) | |
# copy the reference solution | |
for f in os.listdir(join(problem_dir, ref_sol)): | |
name, ext = splitext(f) | |
if (ext == ".cpp"): | |
shutil.copy(join(problem_dir, ref_sol, f), | |
join(directories["sol"], f)) | |
# copy the output checker | |
for f in os.listdir(join(problem_dir, "tests")): | |
if (f == "checker.cpp"): | |
shutil.copy(join(problem_dir, "tests", f), directories["etc"]) | |
# end output | |
for problem, ref_sol, _ in problem_list: | |
output(problem, ref_sol) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment