QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#860835 | #9978. Keystone Correction | ucup-team055# | RE | 0ms | 0kb | Python3 | 2.3kb | 2025-01-18 15:07:49 | 2025-01-18 15:14:51 |
answer
from itertools import product
N, M = map(int, input().split())
prev = (100, 0)
def check(time: str, num_try: str, tries: str) -> bool:
if len(time) > 3:
return False
if len(time) == 3 and not ("100" <= time <= "299"):
return False
if len(time) == 2 and time[0] == "0":
return False
if len(num_try) > 3:
return False
if len(num_try) == 3 and num_try != "100":
return False
if num_try[0] == "0":
return False
if tries == "try" and num_try != "1":
return False
if tries == "tries" and num_try == "1":
return False
return True
def solve() -> list[tuple[int, int] | tuple[int, int, str]]:
global prev
mx = (-1, -1)
ans = ""
S = input()
if S == "00":
return [(0, 0)]
T = []
while S:
i = S.index("t")
if S[i+2]=="y":
T.append((S[:i], S[i:i+3]))
S = S[i+3:]
else:
T.append((S[:i], S[i:i+5]))
S = S[i+5:]
for i in range(1, len(T)):
t, tries = T[i]
cand = []
for j in range(len(t)):
time = t[:j]
num_try = t[j:]
if check(time, num_try, tries):
cand.append((time, num_try, tries))
T[i] = cand
T0, tries = T[0]
for k in range(2, len(T0)):
score = T0[:k]
t = T0[k:]
cand = []
for j in range(len(t)):
time = t[:j]
num_try = t[j:]
if check(time, num_try, tries):
cand.append((time, num_try, tries))
T[0] = cand
for scoreboard in product(*T):
ac = 0
penalty = 0
for time, num_try, tries in scoreboard:
if time == "":
continue
ac += 1
penalty += int(time) + 20 * (int(num_try) - 1)
if str(ac) + str(penalty) == score:
if prev >= (ac, -penalty) > mx:
mx = (ac, -penalty)
ans = f"{ac} {penalty} " + " ".join(f"{time} {num_try} {tries}" for time, num_try, tries in scoreboard)
prev = mx
ans = ans.replace(" ", " ")
print(ans)
for _ in range(N):
solve()
詳細信息
Test #1:
score: 0
Runtime Error
input:
2 -20 23 -36 20 23 -36 20 41 -12 -20 41 -12 -50 80 -100 50 79 -100 50 79 -20 -50 80 -20 -1 2 4 1 2 4 1 3 5 -1 3 5 -20 6 0 20 6 0 20 6 20 -20 6 20