Submission #1164288

#TimeUsernameProblemLanguageResultExecution timeMemory
1164288cjtsaiFire (BOI24_fire)Pypy 3
Compilation error
0 ms0 KiB
# Preprocess intervals:
for each interval [s, e]:
    if s <= e:
        add interval [s, e]
        add interval [s + M, e + M]
    else:  # s > e, wrap-around
        add interval [s, e + M]

ans = infinity

# Try every starting point T in the range [0, M)
for each candidate T that is a valid start:
    current_end = T
    count = 0
    while current_end < T + M:
         # among all intervals with start <= current_end, choose one with max end
         best = max( end for interval if interval.start <= current_end )
         if best <= current_end:
             break  # gap found, cannot cover
         current_end = best
         count += 1
    if current_end >= T + M:
         ans = min(ans, count)

if ans is infinity:
    print(-1)
else:
    print(ans)

Compilation message (stdout)

Compiling 'Main.py'...
***   File "Main.py", line 2
    for each interval [s, e]:
        ^
SyntaxError: invalid syntax. Perhaps you forgot a comma?


=======