神秘脚本 + 神秘颜色

· · 个人记录

import os
import time

problem = "sequence"
grader_name = "grader"

def compile_cpp():
    os.system(f"g++ -std=gnu++17 -O2 -Wall -pipe -static -o {problem} {grader_name}.cpp {problem}.cpp")

def run_cpp():
    os.system(f"./{problem}")

tests = [
    'sample-1',
    'sample-2',
    'sample-3',
]

compile_cpp()

print("compile finish")

for test in tests:
    os.system(f"cp {test}.in 0.in")
    print(f"run test {test}")
    p1 = time.time()
    run_cpp()
    p2 = time.time()
    o = os.system(f"diff 0.out {test}.out -w")
    if o:
        print("\033[91m" + "WA %.5f" % (p2 - p1) + "\033[0m")
    else:
        print("\033[92m" + "OK %.5f" % (p2 - p1) + "\033[0m")

#22B866 #069A4F