QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#860835#9978. Keystone Correctionucup-team055#RE 0ms0kbPython32.3kb2025-01-18 15:07:492025-01-18 15:14:51

Judging History

你现在查看的是最新测评结果

  • [2025-01-18 15:14:51]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2025-01-18 15:07:49]
  • 提交

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

output:


result: