-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_verifyproblem_output.py
executable file
·79 lines (68 loc) · 2.76 KB
/
check_verifyproblem_output.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/python3
import re, sys
class SubmissionInfo:
def __init__(self, submission_type, filename, language, status, verdict, points, extra):
self.submission_type = submission_type
self.filename = filename
self.language = language
self.status = status
self.verdict = verdict
self.points = int(points)
self.extra = extra
def __str__(self):
return str(self.__dict__)
problemname = sys.argv[1]
num_groups = int(sys.argv[2]) if len(sys.argv) > 2 else 1
print("problemname: {}".format(problemname))
exit_code = 0
PATTERN = '^\\s*(P?AC) submission (.*) \\((.*)\\) (.*): (.*) \\((.*)\\) (.*)\n$'
pointset = set()
pattern = re.compile(PATTERN)
has_wa = False
has_tle = False
has_rte = False
last_line = ""
for line in sys.stdin:
pac_match = pattern.match(line)
if pac_match:
info = SubmissionInfo(*pac_match.groups())
pointset.add(info.points)
has_score_pattern = re.compile(".*_\d*\\..*".format(info.points))
filename_pattern = re.compile(".*_{}\\..*".format(info.points))
if has_score_pattern.match(info.filename) and not filename_pattern.match(info.filename):
print("::warning file={},title=Solution score mismatch::Solution {} scored {} instead of the expected amount".format(info.filename, info.filename, info.points))
elif line.strip().startswith('WA submission'):
has_wa = True
pointset.add(0)
elif line.strip().startswith('TLE submission'):
has_tle = True
pointset.add(0)
elif line.strip().startswith('RTE submission'):
has_rte = True
pointset.add(0)
elif line.startswith('ERROR'):
print("::error title=Error while verifying problem {}::{}".format(problemname, line))
exit_code = 1
elif line.startswith('WARNING'):
print("::warning title=Warning while verifying problem {}::{}".format(problemname, line))
if line:
last_line = line
print("Checking for final errors")
error_count = int(last_line.split()[2])
if error_count > 0:
print("::error title=Error(s) while verifying problem {}::{}".format(problemname, last_line))
exit_code = 1
print("num_groups: {}".format(num_groups))
print("pointset: {}".format(pointset))
if 0 not in pointset:
print("::error title=Missing rejected solution::No solution scores 0 points")
exit_code = 1
if not has_wa:
print("::warning title=Missing WA solution::No solution gets Wrong Answer verdict")
exit_code = 1
if not has_tle:
print("::warning title=Missing TLE solution::No solution gets Time Limit Exceeded verdict")
if len(pointset.difference(set([0]))) < num_groups:
print("::error title=Missing model solution::At least one test group is missing a model solution")
exit_code = 1
sys.exit(exit_code)