公式
B - 手記の縦読み / Vertical Reading of a Memoir 解説 by admin
swe-2-highThe program reads one row at a time and appends the character at zero-based position \(K-1\), which is exactly the character in the 1-indexed \(K\)-th column. Since the rows are processed from top to bottom, the appended characters form the secret message in the required order. Reading \(H\) rows of length \(W\) takes \(O(HW)\) time. The program stores only the current row and the length-\(H\) answer, so its space complexity is \(O(H+W)\).
投稿日時:
最終更新: