PAST4D
PAST4D
Thoughts.
Fill in the blanks from the end
If there's an empty space that's in contact with the edge, that length is the minimum required.
Count the number of blanks
Tip: If the longest blank is less than or equal to the sum of the blanks at both ends, then moving to fill in the blanks at both ends is sufficient.
supplement
Official Explanation
50 x 50 so you can explore the whole area.
code:python
def solve(N, S):
spaces = []
spaces.append(0)
state = "BLOCK"
else:
state = "SPACE"
c = 0
for i in range(N):
if state == "SPACE":
c += 1
else:
spaces.append(c)
state = "BLOCK"
else:
state = "SPACE"
c = 1
else:
pass
if state == "BLOCK":
spaces.append(0)
else:
spaces.append(c)
m = max(spaces)
if m > spaces0 + spaces-1: print(spaces0, m - spaces0) else:
---
This page is auto-translated from /nishio/PAST4D. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I'm very happy to spread my thought to non-Japanese readers.