公式

B - 花園の列 / Flower Garden Columns 解説 by admin 印刷ページ

swe-2-high

The number of flowers in column \(j\) is obtained by counting how many rows have F at position \(j\). The program computes this count \(c\) for every column and updates the best value and its index only when \(c\) strictly exceeds the current best. Because the comparison is strict (\(c > \) best), a later column with the same count never replaces the stored one, so the index left at the end is the leftmost column attaining the maximum. Every cell is visited once, giving \(O(HW)\) time, and the whole grid is stored, giving \(O(HW)\) space. Since there is at least one column, the best index is always set before printing.

投稿日時:
最終更新: