A. Letter
time limit per test

1 second

memory limit per test

64 megabytes

input

standard input

output

standard output

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 test(s)
input
6 7
.......
..***..
..*....
..***..
..*....
..***..
output
***
*..
***
*..
***
input
3 3
***
*.*
***
output
***
*.*
***

代码

#include "stdio.h"
#include "string.h"
#include "stdlib.h"
char mapx[55][55];
int a,b;
int is_emh( int i ) {
{
int k=0,j;
for ( j=0; j<b; j++ ) {
if ( mapx[i][j]=='.' )
k++;
}
if ( k==b )
return 1;
return 0;
}
} int is_eml( int i ) {
{
int k=0;
int j;
for ( j=0; j<a; j++ ) {
if ( mapx[j][i]=='.' )
k++;
}
if ( k==a )
return 1;
return 0;
}
} int main( ) {
int i,j;
while ( ~scanf( "%d%d",&a,&b ) ) {
for ( i=0; i<a; i++ )
{
scanf( "%s",&mapx[i] );
} for ( i=0; i<a; i++ ) {
if ( is_emh( i ) )
continue;
for ( j=0; j<b; j++ ) {
if ( is_eml( j ) )
continue;
printf("%c",mapx[i][j]);
}
printf("\n");
}
}
return 0;
}

codeforce -14A A. Letter的更多相关文章

  1. codeforces 14A - Letter & codeforces 859B - Lazy Security Guard - [周赛水题]

    就像title说的,是昨天(2017/9/17)周赛的两道水题…… 题目链接:http://codeforces.com/problemset/problem/14/A time limit per ...

  2. codeforce 1311 C. Perform the Combo 前缀和

    You want to perform the combo on your opponent in one popular fighting game. The combo is the string ...

  3. [LeetCode] Letter Combinations of a Phone Number 电话号码的字母组合

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  4. 17. Letter Combinations of a Phone Number

    题目: Given a digit string, return all possible letter combinations that the number could represent. A ...

  5. 什么是Unicode letter

    起因:从一段代码说起 using System; using System.Collections.Generic; using System.Linq; using System.Text; usi ...

  6. LeetCode——Letter Combinations of a Phone Number

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  7. No.017:Letter Combinations of a Phone Number

    问题: Given a digit string, return all possible letter combinations that the number could represent.A ...

  8. SCI/EI期刊投稿 Reply Letter 常用格式总结

    SCI/EI期刊投稿Reply Letter常用格式总结          整个论文投稿的过程中,会遇到各种问题,需要我们向主编询问或是回复.下面主要总结了responses to the comme ...

  9. 【leetcode】 Letter Combinations of a Phone Number(middle)

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

随机推荐

  1. SpringMVC 图片上传虚拟目录

    可以直接在tomcat的server.xml文件中进行设置,位置在Host中 添加内容为:<Context docBase="G:\JAVAtest\temp" path=& ...

  2. Excel自定义格式参数

    一.自定义格式 方式一:代码结构组成代码分为四个部分,中间用“:”号分隔,具体如下:正数格式:负数格式:零格式:文本格式 两个代码部分,则第一部分用于正数和零和文本,第二部分用于负数 一个代码部分,则 ...

  3. Python学习笔记整理总结【Django】:Model操作(一)

    Model操作(一) 一.Django ORM基本配置 ORM:关系对象映射(Object Relational Mapping,简称ORM)db Frist:到目前为止,当我们的程序涉及到数据库相关 ...

  4. python压测工具Locust

    python压测工具Locust Locust介绍 Locust作为基于Python语言的性能测试框架. 其优点在于他的并发量可以实现单机10倍于LoadRunner和Jmeter工具.他的工作原理为 ...

  5. springboot 2.1.3 + mybatis + druid配置多数据源

    在一些大型的项目中,通常会选择多数据库来满足一些业务需求,此处讲解使用springboot.mybatis和druid来配置多数据源 1.依赖配置 pom文件引入相关依赖 <dependency ...

  6. 动态set mybatis与ibatis的写法

    mybatis: <set> <if test="obj.buyerId != null"> buyerId = #{obj.buyerId}, </ ...

  7. mybatis collection和association使用区别

    1. association-关联,用于一对一(如人与身份证)和多对一(如班级和学生) 2. collection-集合,用于一对多(如学生和班级)的关系

  8. 【ASP.NET-中级】SQLHelper数据访问公共类

    ASP.NET开发中的三层开发思想指的是UI层(界面显示层),BLL层(业务逻辑层),DAL层(数据访问层)三层,三层之间通过函数的调用来达到降低耦合,易于系统维护的目的,SQLHelper助手类的主 ...

  9. C++ProtoBuf的安装与使用

    目录 安装(Ubuntu 16.04) 简介 proto2 proto3 用法 proto3 输出结果 总结 @(目录) 安装(Ubuntu 16.04) sudo apt-get install a ...

  10. .Net Core 微服务容器系列基础目录篇

    1.开场白 HI,各位老铁,大家端午好,之前写了些关于.net core商城系列的文章,有点乱,今天心血来潮想着整理一下(今天只是先把目录列出来,后面的每篇文章这两天会进行重新修改的,目前先将就看下) ...