B - 花園の列 / Flower Garden Columns Editorial by admin Editorial for printing
swe-2-highThe 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.
posted:
last update: