Exemple #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)
Exemple #2
0
        shutil.rmtree('./tmp', ignore_errors=False)
    except:
        pass
    os.mkdir('./tmp')

    TESTS = [
        test.name[:-3] for test in os.scandir('./teste')
        if test.name[-3:] == '.in'
    ]
    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()
Exemple #3
0
    REALMAXV = int(input("REALMAXV = "))

    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")
Exemple #4
0
    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")
Exemple #5
0
    MAXK2 = int(input("MAXK2 = "))

    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)
        K1 = random.randint(1, min(MAXK1, N))
        K2 = random.randint(1, min(MAXK2, N))
        if test == TESTS:
            N, K1, K2 = MAXN, MAXK1, MAXK2
        subprocess.check_call(["./gen", str(N), str(K1), str(K2)], stdout=open("./tmp/"+problem_name()+".in", "w"))
        print("(N = %d, K1 = %d, K2 = %d): " % (N, K1, K2), end="")
        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")
Exemple #6
0
from common import problem_name
#generat teste in fct de sursa corecta

if __name__ == '__main__':
    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")

        testno = "./teste/%d-" % test
        subprocess.check_call([
            "cp", "./tmp/" + problem_name() + ".in",
            testno + problem_name() + ".in"
        ])
        subprocess.check_call(["touch", testno + problem_name() + ".ok"])
        print("Done")
Exemple #7
0
        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)
Exemple #8
0
def run_source_smen(source):
    print("Running %s.................. " % source, end="")
    try:
        shutil.rmtree('./tmp/current')
    except:
        pass
    os.mkdir("./tmp/current")
    subprocess.check_call(
        ["cp", "./surse/" + source, "./tmp/current/" + source])
    subprocess.check_call(["cp", "./prepare/prepare0", "./tmp/prepare0"])
    subprocess.check_call(["cp", "./prepare/prepare1", "./tmp/prepare1"])
    subprocess.check_call(["cp", "./prepare/verif", "./tmp/verif"])

    os.chdir("./tmp")
    try:
        subprocess.check_call(["./prepare0"], timeout=10)
    except:
        os.chdir("../")
        print("Exception-1")
        return False
    os.chdir("../")

    subprocess.check_call([
        "cp", "./tmp/" + problem_name() + ".in.0",
        "./tmp/current/" + problem_name() + ".in"
    ])

    os.chdir("./tmp/current")
    try:
        subprocess.check_call(["./" + source], timeout=time_limit())
    except:
        os.chdir("../../")
        print("Exception-2")
        return False
    os.chdir("../../")

    subprocess.check_call([
        "cp", "./tmp/current/" + problem_name() + ".out",
        "./tmp/" + problem_name() + ".out.0"
    ])

    os.chdir("./tmp")
    try:
        subprocess.check_call(["./prepare1"], timeout=10)
    except:
        os.chdir("../")
        print("Exception-3")
        return False
    os.chdir("../")

    subprocess.check_call([
        "cp", "./tmp/" + problem_name() + ".in.1",
        "./tmp/current/" + problem_name() + ".in"
    ])

    os.chdir("./tmp/current")
    try:
        subprocess.check_call(["./" + source], timeout=time_limit())
    except:
        os.chdir("../../")
        print("Exception-4")
        return False
    os.chdir("../../")

    subprocess.check_call([
        "cp", "./tmp/current/" + problem_name() + ".out",
        "./tmp/" + problem_name() + ".out.1"
    ])

    os.chdir("./tmp")
    try:
        process = subprocess.Popen("./verif",
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
        out = process.stdout.readline()
        print("Mesaj Verif: %s" % out)
        optr = [int(s) for s in out.split() if s.isdigit()]
        result = open("op.ok", "w+")
        result.write("%s" % optr[0])
        result.close()
    except:
        os.chdir("../")
        print("Exception-5")
        return False
    os.chdir("../")

    shutil.rmtree("./tmp/current")
    return True
Exemple #9
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")
Exemple #10
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="")

        FILL = random.randint(1, MAXFILL)
        EMPTY = random.randint(0, MAXEMPTY)
        PARTS = random.randint(1, min(MAXPARTS, FILL))
        ZERO = random.randint(0, min(PARTS - 1, MAXZERO))
        if test == TESTS:
            FILL, EMPTY, PARTS, ZERO = MAXFILL, MAXEMPTY, MAXPARTS, MAXZERO
        subprocess.check_call(["./gen", str(FILL), str(EMPTY), str(PARTS), str(ZERO)], stdout=open("./tmp/"+problem_name()+".in", "w"))
        print("(FILL = %d, EMPTY = %d, PARTS = %d, ZERO = %d): " % (FILL, EMPTY, PARTS, ZERO), end="")
        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")