A. Letter

题目连接:

http://www.codeforces.com/contest/14/problem/A

Description

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.

Input

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.

Output

Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.

Sample Input

6 7

.......

....

..
....

..
..

..
....

..***..

Sample Output


*..


*..


Hint

题意

让你找到最小的矩形,使得这个矩形能够包含所有的*

题解:

水题嘛,记录最左上角和最右下角就好了。

代码

#include<bits/stdc++.h>
using namespace std;
string s[55];
int main(){
int n,m;
scanf("%d%d",&n,&m);
int ix=1e9,iy=1e9,ax=0,ay=0;
for(int i=0;i<n;i++){
cin>>s[i];
for(int j=0;j<m;j++){
if(s[i][j]=='*')
ix=min(ix,i),iy=min(iy,j),ax=max(ax,i),ay=max(ay,j);
}
}
for(int i=ix;i<=ax;i++){
for(int j=iy;j<=ay;j++){
cout<<s[i][j];
}
cout<<endl;
}
}

Codeforces Beta Round #14 (Div. 2) A. Letter 水题的更多相关文章

  1. Codeforces Beta Round #97 (Div. 1) A. Replacement 水题

    A. Replacement 题目连接: http://codeforces.com/contest/135/problem/A Description Little Petya very much ...

  2. Codeforces Beta Round #14 (Div. 2)

    Codeforces Beta Round #14 (Div. 2) http://codeforces.com/contest/14 A 找最大最小的行列值即可 #include<bits/s ...

  3. Codeforces Beta Round #14 (Div. 2) D. Two Paths 树形dp

    D. Two Paths 题目连接: http://codeforces.com/contest/14/problem/D Description As you know, Bob's brother ...

  4. Codeforces Beta Round #14 (Div. 2) C. Four Segments 水题

    C. Four Segments 题目连接: http://codeforces.com/contest/14/problem/C Description Several months later A ...

  5. Codeforces Beta Round #14 (Div. 2) B. Young Photographer 水题

    B. Young Photographer 题目连接: http://codeforces.com/contest/14/problem/B Description Among other thing ...

  6. Codeforces Beta Round #14 (Div. 2) D. Two Paths 树的直径

    题目链接: http://codeforces.com/contest/14/problem/D D. Two Paths time limit per test2 secondsmemory lim ...

  7. Codeforces Beta Round #14 (Div. 2) Two Paths (树形DP)

    Two Paths time limit per test 2 seconds memory limit per test 64 megabytes input standard input outp ...

  8. TTTTTTTTTTTTT 树的直径 Codeforces Beta Round #14 (Div. 2) D. Two Paths

    tiyi:给你n个节点和n-1条边(无环),求在这个图中找到 两条路径,两路径不相交,求能找的两条路径的长度的乘积最大值: #include <iostream> #include < ...

  9. Codeforces Beta Round #10 A. Power Consumption Calculation 水题

    A. Power Consumption Calculation 题目连接: http://www.codeforces.com/contest/10/problem/A Description To ...

随机推荐

  1. bzoj千题计划212:bzoj1864: [Zjoi2006]三色二叉树

    http://www.lydsy.com/JudgeOnline/problem.php?id=1864 #include<cstdio> #include<cstring> ...

  2. Linux命令(五)免密码远程登录和配置别名

    1. ssh-keygen 2. ssh-copy-id -p port user@remote .ssh中建立并编辑config文件 原来需要 ssh -p ubuntu@xxx.xxx.xxx 现 ...

  3. JavaScript的单线程性质以及定时器的工作原理

    前些日子还在网上争论过js动画用setTimeout还是setInterval,个人偏向于setTimeout,当动画中牵扯到ajax时用setInterval会有时间偏差,出现一些问题即使用clea ...

  4. 在ASP.Net中两种利用CSS实现多界面的方法

    通过使页面动态加载不同CSS实现多界面(类型于csdn的blog): 方法一: <%@page language="C#"%><%@import namespac ...

  5. 如何使用 grunt

    1>. 首先要有nodejs环境, 至少0.8.0版本: 2>. 转到 项目文件夹下: >npm install –g grunt-cli >npm init #生成一个基本的 ...

  6. 用Emacs将文件加密保存

    为Emacs安装ps-ccrypt插件. 如果你在使用elpa(Emacs的一个插件管理器), 可以M-x list-packages, 从插件列表中找到 ps-ccrypt, 在该项上按i将其标记为 ...

  7. 02 uni-app框架学习:设置全局样式统一每个页面的背景颜色

    1.设置全局样式可以在App.vue里面 2.在每个页面的根view 里添加一个class名叫page

  8. springcloud中的API网关服务Zuul

    到目前为止,我们Spring Cloud中的内容已经介绍了很多了,Ribbon.Hystrix.Feign这些知识点大家都耳熟能详了,我们在前文也提到过微服务就是把一个大的项目拆分成很多小的独立模块, ...

  9. centos7 部署 docker、shipyard

    =============================================== 2019/4/9_第3次修改                       ccb_warlock 更新说 ...

  10. wpf image 指定Stretch="None" 不拉伸的时候,仍然拉伸的解决办法

    I think TI82 is right on this issue. The image become bigger than you expect because its dpi doesn't ...