/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 233 点
問題文
高橋君は縦 H 行、横 W 列のマス目でできた宝物の地図を持っています。地図の様子は H 個の文字列 S_1, S_2, \ldots, S_H で表され、 S_i の j 文字目は上から i 行目、左から j 列目のマスの様子です。 T は宝物が埋まっていることを、 . は何もないことを表します。
各行について、その行に宝物が 1 つ以上あるかどうかを調べ、あるなら o 、ないなら x として、上の行から順に並べた長さ H の文字列を出力してください。
制約
- 1 \leq H \leq 10
- 1 \leq W \leq 10
- S_i は
Tと.のみからなる長さ W の文字列
入力
入力は以下の形式で標準入力から与えられる。
H W S_1 S_2 \vdots S_H
- 1 行目には、地図の行数 H と列数 W がスペース区切りで与えられる。
- 2 行目から H 行にわたり、 1 + i 行目には上から i 行目の様子を表す文字列 S_i が与えられる。
出力
長さ H の文字列を 1 行で出力せよ。
入力例 1
2 2 T. ..
出力例 1
ox
入力例 2
3 3 ... .T. ...
出力例 2
xox
入力例 3
1 1 T
出力例 3
o
入力例 4
2 2 .. ..
出力例 4
xx
入力例 5
3 3 T.T ... T.T
出力例 5
oxo
Score : 233 pts
Problem Statement
Takahashi has a treasure map made of a grid with H rows and W columns. The map is described by H strings S_1, S_2, \ldots, S_H, where the j-th character of S_i represents the cell in the i-th row from the top and the j-th column from the left. T means a treasure is buried there, and . means there is nothing.
For each row, determine whether the row contains at least one treasure. Output a string of length H consisting of o (if it does) or x (if it does not), listed from the top row to the bottom row.
Constraints
- 1 \leq H \leq 10
- 1 \leq W \leq 10
- S_i is a string of length W consisting only of
Tand.
Input
The input is given from standard input in the following format:
H W S_1 S_2 \vdots S_H
- The first line contains the number of rows H and the number of columns W of the map, separated by a space.
- The next H lines follow: the (1 + i)-th line contains the string S_i describing the i-th row from the top.
Output
Print a single line containing a string of length H.
Sample Input 1
2 2 T. ..
Sample Output 1
ox
Sample Input 2
3 3 ... .T. ...
Sample Output 2
xox
Sample Input 3
1 1 T
Sample Output 3
o
Sample Input 4
2 2 .. ..
Sample Output 4
xx
Sample Input 5
3 3 T.T ... T.T
Sample Output 5
oxo