CF14A.Letter
入门
通过率:0%
时间限制:1.00s
内存限制:64MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle's sides should be parallel to the sheet's sides.
男孩鲍勃喜欢画画。不久前,他买了一张有 n 行 m 列的矩形方格纸(带网格线)。鲍勃涂黑了纸上的若干个方格。当他欣赏完自己的杰作后,决定将其分享给住在平面国(Flatland)的哥哥。现在鲍勃需要通过邮局寄出这幅画,但由于世界经济危机和高昂的油价,他希望在寄出作品的同时尽可能节省开支。每寄送一个纸上的方格(无论是否被涂黑),鲍勃都需要支付 3.14 布尔币(burles)。请帮助鲍勃从他的杰作中裁剪出一个包含所有涂黑方格的、花费最少的矩形区域。该矩形的边必须与纸张的边平行。
输入格式
The first line of the input data contains numbers n and m (1 ≤ n, m ≤ 50), n — amount of lines, and m — amount of columns on Bob's sheet. The following n lines contain m characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square.
输入数据的第一行包含两个整数 n 和 m(1 ≤ n, m ≤ 50),其中 n 表示 Bob 的纸张的行数,m 表示列数。接下来的 n 行,每行包含 m 个字符。字符 . 表示纸张上未被涂黑的方格,字符 * 表示已被涂黑的方格。题目保证 Bob 至少涂黑了一个方格。
输出格式
Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.
输出成本最小的所需矩形。请参考样例测试中的输出数据,以更好地理解输出格式。
输入输出样例
输入#1
6 7 ....... ..***.. ..*.... ..***.. ..*.... ..***..
输出#1
*** *.. *** *.. ***
输入#2
3 3 *** *.* ***
输出#2
*** *.* ***
输入解题思路,AI测评打分。不知道怎么写?