Official
B - 饂飩屋の席 / Seats in an Udon Restaurant Editorial by admin
swe-2-highEditorial
Read the rows top to bottom and count the dots . (empty seats) in each. Whenever a row’s count c is strictly greater than the best seen so far, update best and remember the row index idx. Using a strict c > best comparison means that when several rows tie for the maximum, the first (topmost) one found is kept, which is exactly the tie-breaking rule required. After all rows are processed, idx is the topmost row with the most empty seats.
Counting one row costs \(O(W)\), giving \(O(HW)\) total time. We store only one row’s string and a few counters, so memory is \(O(W)\) beyond the output — \(O(HW)\) if the whole input is counted.