예제 #1
0
def gen(test: int) -> None:
    print("Generating test {}".format(test))
    ARGS = TESTS[test].split()

    os.makedirs(Path(temp_in(test)).parent, exist_ok=True)
    os.makedirs(Path(temp_out(official_source_name(), test)).parent, exist_ok=True)

    subprocess.check_call(["./"+gen_name()] + ARGS, stdout=open(temp_in(test), "w"))
    print("Done generating in for {}".format(test), flush=True)

    print("Running {} for {}".format(official_source_name(),test), flush=True)
    if run_source(official_source_name(), test, True) == False:
        print("Source error on test {}".format(test))
        exit(1)

    testno = "./teste/%d-" % test
    subprocess.check_call(["cp", temp_in(test), testno+problem_name()+".in"])
    subprocess.check_call(["cp", temp_out(official_source_name(), test), testno+problem_name()+".ok"])
    print("Done generating ok for {}".format(test), flush=True)
예제 #2
0
    ]
    SCORES = {source: 0 for source in SOURCES}
    RESULTS = {source: [] for source in SOURCES}
    for test in range(len(TESTS)):
        print(".", end="")
        stdout.flush()
        subprocess.check_call([
            "cp", "./teste/" + str(test) + "-" + problem_name() + ".in",
            temp_in(test)
        ])
        subprocess.check_call([
            "cp", "./teste/" + str(test) + "-" + problem_name() + ".ok",
            temp_ok(test)
        ])

        for source in SOURCES:
            if run_source(source, test) == False:
                RESULTS[source] += ['X']
            else:
                s = score(source, test)
                RESULTS[source] += [str(s)]
                SCORES[source] += s
    print()
    SCORES = [[name, score] for name, score in SCORES.items()]
    RESULTS = [[name] + results for name, results in RESULTS.items()]

    print(tabulate.tabulate(SCORES, ["Nume", "Scor"], tablefmt="grid"))
    print(
        tabulate.tabulate(RESULTS, ["Nume"] + list(range(len(TESTS))),
                          tablefmt="grid"))
예제 #3
0
    try:
        shutil.rmtree('./tmp', ignore_errors=False)
    except:
        pass
    os.mkdir('./tmp')

    for test in range(1, TESTS + 1):
        print("Case #%d: " % test, end="")
        

        N = random.randint(3, MAXN)


        subprocess.check_call(["./gen", str(N), str(MAXV), str(REALMAXV), str(random.randint(0, 2**32 - 1))], stdout=open("./tmp/"+problem_name()+".in", "w"))



        for source in Sources:
            if run_source(source) == False:
                print("Runtime error on %s" % source)
                exit(1)

        subprocess.check_call(["cp", "./tmp/%s.out" % Sources[0], "./tmp/"+problem_name()+".ok"])

        for source in Sources:
            if score(source) != 5:
                print("Wrong answer: %s" % source)
                exit(1)
        print("OK")
예제 #4
0
파일: eval.py 프로젝트: adrian-budau/work
    MAXPART = int(input("MAXPART = "))
    MAXV = int(input("MAXV = "))
    try:
        shutil.rmtree('./tmp', ignore_errors=False)
    except:
        pass
    os.mkdir('./tmp')

    for test in range(1, TESTS + 1):
        print("Case #%d: " % test, end="")

        N = random.randint(1, MAXN)
        K = random.randint(1, min(N, MAXK))
        X = random.randint(1, min(MAXX, N))
        Y = random.randint(1, min(MAXY, N))
        PART = random.randint(1, min(X, Y, MAXPART))
        subprocess.check_call(["./gen", str(N), str(K), str(X), str(Y), str(PART), str(MAXV), str(random.randint(0, 2**32 - 1))], stdout=open("./tmp/"+problem_name()+".in", "w"))

        for source in Sources:
            if run_source(source) == False:
                print("Runtime error on %s" % source)
                exit(1)

        subprocess.check_call(["cp", "./tmp/%s.out" % Sources[0], "./tmp/"+problem_name()+".ok"])

        for source in Sources:
            if score(source) != 10:
                print("Wrong answer: %s" % source)
                exit(1)
        print("OK")
예제 #5
0
import subprocess
import shutil
from common import cpp_compile, run_source, official_source_name, problem_name
#generat teste in fct de sursa corecta


if __name__ == '__main__':
    cpp_compile(official_source_name())
    try:
        shutil.rmtree('./tmp', ignore_errors=False)
    except:
        pass
    os.mkdir('./tmp')

    TESTS = [line.strip() for line in open("./teste/teste.txt") if len(line.strip()) > 0 and line.strip()[0] != '#']
    for test in range(len(TESTS)):
        print("Test %d:" % test)
        ARGS = TESTS[test].split()

        print("  Generating ...................... ", end="")
        subprocess.check_call(["./gen"] + ARGS, stdout=open("./tmp/"+problem_name()+".in", "w"))
        print("Done")
        print("  Running "+official_source_name()+" for output ... ", end="")
        if run_source(official_source_name()) == False:
            print("Error")
            exit(1)

        testno = "./teste/%d-" % test
        subprocess.check_call(["cp", "./tmp/"+problem_name()+".in", testno+problem_name()+".in"])
        subprocess.check_call(["cp", "./tmp/"+official_source_name()+".out", testno+problem_name()+".ok"])
        print("Done")
예제 #6
0
    MAXV = 10**9

    try:
        shutil.rmtree('./tmp', ignore_errors=False)
    except:
        pass
    os.mkdir('./tmp')

    for test in range(1, TESTS + 1):
        print("Case #%d: " % test, end="")

        N = random.randint(2, MAXN)
        subprocess.check_call(
            ["./" + gen_name(), str(N), str(MAXV)],
            stdout=open(temp_in(TEST_IDX), "w"))

        for source in Sources:
            if run_source(source, TEST_IDX, True) == False:
                print("Runtime error on %s" % source)
                exit(1)

        subprocess.check_call(
            ["cp", temp_out(Sources[0], TEST_IDX),
             temp_ok(TEST_IDX)])

        for source in Sources:
            if score(source, TEST_IDX) != 5:
                print("Wrong answer: %s" % source)
                exit(1)
        print("OK")