diff --git a/.gitignore b/.gitignore index 285947d..016c696 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .vscode/ # Test -test* \ No newline at end of file +test* +test/ \ No newline at end of file diff --git a/vcheck.py b/vcheck.py index 24b1976..4b018f4 100644 --- a/vcheck.py +++ b/vcheck.py @@ -62,7 +62,7 @@ def check_file(file_path: str, err_msg: str): task_cnt = [] -vconf = open("vaccept.conf", "r") +vconf = open("vtest.conf", "r") name, sub_tasks = vconf.readline().split() sub_tasks = int(sub_tasks) @@ -83,15 +83,15 @@ ac = 0 wa = 0 re = 0 -for i in range(0, sub_tasks): +for i in range(1, sub_tasks + 1): print("Start checking subtask #{}".format(i)) - for j in range(0, task_cnt[i]): + for j in range(1, task_cnt[i - 1] + 1): tot_id += 1 exe_path = "./run_{}".format(name) - in_path = "{}.{}.{}.in".format(name, i + 1, j + 1) + in_path = "{}.{}.{}.in".format(name, i, j) out_path = ".output.tmp" - ans_path = "{}.{}.{}.out".format(name, i + 1, j + 1) + ans_path = "{}.{}.{}.out".format(name, i, j) check_file(exe_path, "[ERR] Executable file {} not found.".format(exe_path)) check_file(in_path, "[ERR] Input file {} not found.".format(in_path)) @@ -111,8 +111,9 @@ for i in range(0, sub_tasks): re += 1 print( - " Case #{}: {} ({}ms) [{}%]".format( - tot_id, + " Case #{}.{}: {} ({}ms) [{}%]".format( + i, + j, res_str, round(elapsed_time * 1000, 2), round((tot_id / tot_tasks) * 100), @@ -121,9 +122,21 @@ for i in range(0, sub_tasks): tot_end_time = time.time() -print("\nSummary:") +print("\nSummary:", end="") +if wa != 0: + print(" WA", end="") +if re != 0: + print(" RE", end="") +if wa == 0 and re == 0: + print(" AC", end="") + +print() print(" Total time: {}ms".format(round((tot_end_time - tot_start_time) * 1000, 2))) -print(" Slowest case: #{}.{} ({}ms)".format(max_case[0] + 1, max_case[1] + 1, round(max_time * 1000, 2))) +print( + " Slowest case: #{}.{} ({}ms)".format( + max_case[0], max_case[1], round(max_time * 1000, 2) + ) +) print("--------------------------------") print(" AC: {} [{}%]".format(ac, ac * 100 // tot_tasks)) print(" WA: {} [{}%]".format(wa, wa * 100 // tot_tasks)) diff --git a/vmake.py b/vmake.py new file mode 100644 index 0000000..9dd8fb6 --- /dev/null +++ b/vmake.py @@ -0,0 +1,110 @@ +import subprocess +import time +import sys +import os + + +def run(name: str, in_path, out_path): + in_file = open(in_path, mode="r") + out_file = open(out_path, mode="w") + + start_time = time.time() + code = subprocess.call(name, stdin=in_file, stdout=out_file) + end_time = time.time() + + in_file.close() + out_file.close() + return (end_time - start_time, code) + + +def check_file(file_path: str, err_msg: str): + if not os.path.exists(file_path): + print(err_msg, file=sys.stderr, flush=True) + exit(1) + return + + +task_cnt = [] + +vconf = open("vtest.conf", "r") + +name, sub_tasks = vconf.readline().split() +sub_tasks = int(sub_tasks) +tot_tasks = 0 + +for i in range(0, sub_tasks): + num = int(vconf.readline()) + task_cnt.append(num) + tot_tasks += num + +max_time = -1 +max_case = (0, 0) + +tot_start_time = time.time() +tot_id = 0 + +err_cnt = 0 + +for i in range(1, sub_tasks + 1): + print("Making subtask #{}".format(i)) + + for j in range(1, task_cnt[i - 1] + 1): + tot_id += 1 + mk_path = "./mk_{}".format(name) + std_path = "./std_{}".format(name) + in_path = ".input.tmp" + out_path = "{}.{}.{}.in".format(name, i, j) + ans_path = "{}.{}.{}.out".format(name, i, j) + + check_file(mk_path, "[ERR] Executable file {} not found.".format(mk_path)) + check_file(std_path, "[ERR] Executable file {} not found.".format(std_path)) + + input_tmp = open(in_path, "w") + input_tmp.write(str(i)) + input_tmp.close() + + mk_time, mk_code = run(mk_path, in_path, out_path) + std_time, std_code = run(std_path, out_path, ans_path) + + if mk_code != 0: + print( + "****[ERR] {} Runtime Error on making test-case #{}.{}".format( + mk_path, i, j + ) + ) + + err_cnt += 1 + elif std_code != 0: + print( + "****[ERR] {} Runtime Error on running test-case #{}.{}".format( + std_path, i, j + ) + ) + + err_cnt += 1 + else: + if std_time > max_time: + max_time = std_time + max_case = (i, j) + + print( + " Made case #{}.{}: ({}ms) [{}%]".format( + i, + j, + round(std_time * 1000, 2), + round((tot_id / tot_tasks) * 100), + ) + ) + +tot_end_time = time.time() + +print("\nSummary:") +print(" Total time: {}ms".format(round((tot_end_time - tot_start_time) * 1000, 2))) +print( + " Slowest case: #{}.{} ({}ms)".format( + max_case[0], max_case[1], round(max_time * 1000, 2) + ) +) + +if err_cnt != 0: + print("****[ERR] {} times. [{}%]".format(err_cnt, (err_cnt * 100 // tot_tasks)))