codeforce -14A A. Letter
1 second
64 megabytes
standard input
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.
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 the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.
6 7
.......
..***..
..*....
..***..
..*....
..***..
***
*..
***
*..
***
3 3
***
*.*
***
***
*.*
***
代码
#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的更多相关文章
- codeforces 14A - Letter & codeforces 859B - Lazy Security Guard - [周赛水题]
就像title说的,是昨天(2017/9/17)周赛的两道水题…… 题目链接:http://codeforces.com/problemset/problem/14/A time limit per ...
- 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 ...
- [LeetCode] Letter Combinations of a Phone Number 电话号码的字母组合
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- 17. Letter Combinations of a Phone Number
题目: Given a digit string, return all possible letter combinations that the number could represent. A ...
- 什么是Unicode letter
起因:从一段代码说起 using System; using System.Collections.Generic; using System.Linq; using System.Text; usi ...
- LeetCode——Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- No.017:Letter Combinations of a Phone Number
问题: Given a digit string, return all possible letter combinations that the number could represent.A ...
- SCI/EI期刊投稿 Reply Letter 常用格式总结
SCI/EI期刊投稿Reply Letter常用格式总结 整个论文投稿的过程中,会遇到各种问题,需要我们向主编询问或是回复.下面主要总结了responses to the comme ...
- 【leetcode】 Letter Combinations of a Phone Number(middle)
Given a digit string, return all possible letter combinations that the number could represent. A map ...
随机推荐
- 使用Spreadsheet导出表格时,设置样式
$spreadsheet = new Spreadsheet();// 初始化 $spreadsheet->createSheet();// 添加一个sheet ...
- selenium-04-验证码问题
对于web应用来说,大部分的系统在用户登录时都要求用户输入验证码,验证码的类型的很多,有字母数字的,有汉字的,甚至还要用户输入一条算术题的答案的,对于系统来说使用验证码可以有效果的防止采用机器猜测方法 ...
- java项目打包
http://blog.csdn.net/qq_34845382/article/details/53885907 自己用Rinnable JAR file 方法也可以.更简单.直接点击Finish即 ...
- <<构建之法第三版>>读书遇到的5个问题
1.书中第4章4.5节所说的结对编程让我感觉有一点困惑,书中书写的是结对编程,说实话我是第一次接触这个词汇,我能感到这种方式的新特之处,但是对比我现实的编程经历,我很难想象在一般的企业开发中这样的行为 ...
- Maven 梳理 -聚合与继承
一.聚合 如果我们想一次构建多个项目模块,那我们就需要对多个项目模块进行聚合 1.1.聚合配置代码 1 <modules> 2 <module>模块一</module&g ...
- 让视频丝滑流畅——N/A通用补帧傻瓜解决方案
补帧就是字面意思,把24帧的视频通过算法即时补偿到更高的帧数,获得更优秀的观感体验 索尼大法brivia电视的中高端产品线中的motionflow技术,都可以实现硬件补帧,只需要把动态打开,相应的画面 ...
- Java 学习笔记之 Synchronized锁重入
Synchronized锁重入: 当一个线程得到一个对象锁后,再次请求此对象锁时是可以再次得到该对象的锁.这也证明在一个Synchronized方法/块的内部调用本类的其他Synchronized方法 ...
- ELK 学习笔记之 Logstash之inputs配置
Logstash之inputs配置: input plugin doc: https://www.elastic.co/guide/en/logstash/current/index.html 插件很 ...
- 手把手带你利用Ribbon实现客户端的负载均衡
之前的文章<SpringCloud搭建注册中心与服务注册>介绍了注册中心的搭建和服务的注册,本文将介绍下服务消费者通过Ribbon调用服务实现负载均衡的过程. 本文目录 一.Ribbon服 ...
- Android适配总结
1.dp与px的 密度类型 代表的分辨率 屏幕密度 换算 比例 低密度(ldpi) 240x320 120 1dp=0.75px 3 中密度(mdpi) 320x480 160 1dp = 1px 4 ...