Official

B - 連続正解 / Consecutive Correct Answers Editorial by admin

swe-2-high

A score is earned only while every answer from the first problem onward is correct. In other words, problem \(i\) gets o exactly when \(A_1 = A_2 = \cdots = A_i = 1\), and once a \(0\) appears, everything after it must be x. The program tracks this with a flag alive meaning ‘no mistake so far’, and sets alive to false when \(A_i = 0\) appears. Since alive never becomes true again, all later problems automatically become x, faithfully reproducing the rule. Each problem is processed once, so the time complexity is \(O(N)\), and storing the output string takes \(O(N)\) space.