Comments

About D1, you can reconcile the idea and the code like this: the real constraint isn’t simply “you can’t insert in the middle,” but that any insertion must not break an already satisfied prefix w condition (mex = k). The loop from i = 0 to n − 2 is effectively counting how many insertion positions are safe before the first position where inserting would destroy the existing prefix property. When m = 1, a full segment with mex = k must remain intact, so only the two ends work; when m = 0, as long as the prefix hasn’t reached mex = k yet, inserting won’t affect it, giving i valid positions. From this perspective, the code is implicitly checking the previous w-state rather than explicitly reasoning about “middle vs ends,” so the implementation and the intended logic do line up—just from different angles.

it is crazy for me

On wangmaruiHello 2026 Editorial, 4 months ago
-14

难:)