公式
B - 宝物の地図 / Treasure Map 解説 by admin
swe-2-highEditorial
For each row, we check whether it contains T and append o if it does, x otherwise. The program calls s.find('T'), which scans the string from the left and returns string::npos when no T exists, so it correctly determines whether the row has any treasure. Repeating this from the top row to the bottom builds the answer string in the required order.
Scanning one row takes \(O(W)\) time and there are \(H\) rows, so the total running time is \(O(HW)\). Only one row (\(O(W)\)) and the answer string (\(O(H)\)) are stored at a time, so the memory usage is \(O(H + W)\) — or \(O(HW)\) if you count the entire stored input.