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 ...
随机推荐
- 使用Git工具批量拉取代码
公司项目比较多,每天上班第一件事就是拉取代码,cd A 目录 git pull cd .. cd B ...... 一个项目一个项目的拉取,感觉也是很费劲的,那么有没有什么一键操作呢 现在执行一个命令 ...
- 暑期——第三周总结(Ubuntu系统安装eclipse问题【已解决】)
所花时间:7天 代码行:200(python)+150(java) 博客量:1篇 了解到知识点 : 一: Python: 问题 unresolved reference xrange 解决方案 pyt ...
- Hive安装与简单使用并集成SparkSQL
## Hive环境搭建1. hive下载:http://archive-primary.cloudera.com/cdh5/cdh/5/hive-1.1.0-cdh5.7.0.tar.gzwget h ...
- idea springBoot 配置devtools实现热部署
1.pom文件依赖引入 <dependencies> <dependency> <groupId>org.springframework.boot</grou ...
- hadoop入门之海量Web日志分析 用Hadoop提取KPI统计指标
转载自:http://blog.fens.me/hadoop-mapreduce-log-kpi/ 今天学习了这一篇博客,写得十分好,照着这篇博客敲了一遍. 发现几个问题, 一是这篇博客中采用的had ...
- 基于hap的文件上传和下载
序言 现在,绝大部分的应用程序在很多的情况下都需要使用到文件上传与下载的功能,在本文中结合hap利用spirng mvc实现文件的上传和下载,包括上传下载图片.上传下载文档.前端所使用的技术不限,本文 ...
- Python爬虫(三):BeautifulSoup库
BeautifulSoup 是一个可以从 HTML 或 XML 文件中提取数据的 Python 库,它能够将 HTML 或 XML 转化为可定位的树形结构,并提供了导航.查找.修改功能,它会自动将输入 ...
- 死磕 java线程系列之创建线程的8种方式
(手机横屏看源码更方便) 问题 (1)创建线程有哪几种方式? (2)它们分别有什么运用场景? 简介 创建线程,是多线程编程中最基本的操作,彤哥总结了一下,大概有8种创建线程的方式,你知道吗? 继承Th ...
- JavaWeb http协议的自我描述
1.http协议的组成 http:规范那种协议 localhost.127.0.0.1:访问的ip地址(默认,根据自己的需求改变) 端口号:8080(默认,根据自己的需求改变) 工程:XXX 资源:可 ...
- FreeRTOS优化与错误排查方法
写在前面 主要是为刚接触 FreeRTOS 的用户指出那些新手通常容易遇到的问题.这里把最主要的篇幅放在栈溢出以及栈溢出j检测上,因为栈相关的问题是初学者遇到最多的问题. printf-stdarg. ...