Official
B - 海図の航路 / Sea Chart Lanes Editorial by admin Editorial for printing
swe-2-highFor each column we only need to know whether every cell is sea. The program loops over columns \(j\) in the outer loop and rows \(i\) in the inner loop, checking whether \(g[i][j]\) is #. If any # is found, sea becomes false; otherwise the column can be a lane and the answer is incremented. Each column can be judged independently by scanning it top to bottom, so this exhaustive check counts exactly the valid columns. It inspects every cell once, so the time is \(O(HW)\), and since the whole chart is stored in memory the space is also \(O(HW)\).
posted:
last update: