White Rectangles

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 732    Accepted Submission(s): 368

Problem Description
You are given a chessboard made up of N squares by N squares with equal size. Some of the squares are colored black, and the others are colored white. Please write a program to calculate the number of rectangles which are completely made up of white squares.

Input
There are multiple test cases. Each test case begins with an integer N (1 <= N <= 100), the board size. The following N lines, each with N characters, have only two valid character values:

# - (sharp) representing a black square;
. - (point) representing a white square.

Process to the end of file.

Output
For each test case in the input, your program must output the number of white rectangles, as shown in the sample output.

Sample Input
2
.#
..
4
..#.
##.#
.#..
.#.#

Sample Output
5
15

Author
JIANG, Ming

Source
ZOJ Monthly, January 2004

Recommend
xhd

Enrich my knowledge again.In English ,left corner means the corner on the left and up side of a rectangle,and bottom left means the left and down side of a rectangle,and right side as well.It seems that the word "corner" contains the significance of up side.
Enumerate the left corner of the rectangles ,just count it.

#include<stdio.h>
#include<string.h>
int f[][];
char ch[][];
int main()
{
int n,i,j;
while (scanf("%d",&n)!=EOF)
{
for (i=;i<=n;i++) scanf("%s",&ch[i][]);
memset(f,,sizeof(f));
int ans=;
for (i=;i<=n;i++)
for (j=n;j>=;j--)
if (ch[i][j]=='.') f[i][j]=f[i][j+]+;
for (i=;i<=n;i++)
for (j=;j<=n;j++)
{
int maxlen=f[i][j],v=;
while (maxlen)
{
ans+=maxlen;
v++;
if (f[i+v][j]<maxlen) maxlen=f[i+v][j];
}
}
printf("%d\n",ans);
}
return ;
}

White Rectangles[HDU1510]的更多相关文章

  1. HDU1510 White rectangles

    White Rectangles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  2. HDU1510 White rectangles( 乱搞 O(n^3) )题解

    思路: 友谊赛的时候一直想到了,但是没想出来怎么遍历才能找到所有矩阵,卡住了. 这里讲一下完整思路:我们用一个num[i][j]表示第i行第j列每一列连续的白色格子数量,然后我们定义一个MIN,并且每 ...

  3. 【HDOJ】1510 White Rectangles

    这个题目很好,变形的题目也很多.简单DP. /* 1510 */ #include <cstdio> #include <cstring> #include <cstdl ...

  4. zoj 2067 White Rectangles

    这题解决的算法处理,真的很难想清楚!!尤其是最后的正矩形如何处理.不过终于看懂了 #include<stdio.h> #include<stdlib.h> #include&l ...

  5. PS网页设计教程XXIV——从头设计一个漂亮的网站

    作为编码者,美工基础是偏弱的.我们可以参考一些成熟的网页PS教程,提高自身的设计能力.套用一句话,“熟读唐诗三百首,不会作诗也会吟”. 本系列的教程来源于网上的PS教程,都是国外的,全英文的.本人尝试 ...

  6. Gazebo機器人仿真學習探索筆記(三)機器人模型

    gazebo_models:https://bitbucket.org/osrf/gazebo_models 模型庫下載,可以參考如下命令: ~/Rob_Soft/Gazebo7$ hg clone ...

  7. 【图像处理】Haar-like特征

    特征提取的原理.代码等: 如果是白黑白,是减去一个黑的还是2个黑的,网上有不同的说法:应该需要看原论文了. 论文原文 The sum of the pixels which lie within th ...

  8. Viola–Jones object detection framework--Rapid Object Detection using a Boosted Cascade of Simple Features中文翻译 及 matlab实现(见文末链接)

    ACCEPTED CONFERENCE ON COMPUTER VISION AND PATTERN RECOGNITION 2001 Rapid Object Detection using a B ...

  9. woj1012 Thingk and Count DP好题

    title: woj1012 Thingk and Count DP好题 date: 2020-03-12 categories: acm tags: [acm,dp,woj] 难题,dp好题,几何题 ...

随机推荐

  1. 滑动菜单栏(一)开源项目SlidingMenu的使用

    本帖最后由 user1 于 2013-7-16 21:56 编辑 一.SlidingMenu简介相信大家对SlidingMenu都不陌生了,它是一种比较新的设置界面或配置界面的效果,在主界面左滑或者右 ...

  2. unity3d中资源文件从MAX或者MAYA中导出的注意事项

    原地址:http://blog.sina.com.cn/s/blog_6ad33d3501011ekx.html 之前在项目中,没有怎么接触过美术的软件(之前的美术团队很犀利,被他们宠坏了).在自己公 ...

  3. 腾讯sdk学到了

    1. 获取文本的高度和宽度 + (CGFloat)heightForContent:(MyMsgTextModel *)content withWidth:(CGFloat)width { CGSiz ...

  4. 重构edit 和 new页面

    www.iwangzheng.com 由于edit和new页面的相似部分很多,需要提取出来,现在就是提取的方法 从form 的开始部分选中,shift+v选中对应的行 :Rextract form 然 ...

  5. 修改setup.py的源

    方法一: 修改文件 ~/.pydistutils.cfg为: [easy_install] index_url = http://pypi.douban.com/simple 方法二: 直接在setu ...

  6. 【Python】Python AES 对称加密示例

    代码: import sys from Crypto.Cipher import AES from binascii import b2a_hex, a2b_hex AES_SECRET_KEY = ...

  7. 【转】tomcat下部署 solr 5.3.1

    本文转自:http://blog.csdn.net/lianghyan/article/details/49467207 solr下载: http://lucene.apache.org/solr/d ...

  8. spring无法扫描jar包的问题

    在日常开发中往往会对公共的模块打包发布,然后调用公共包的内容.然而,最近对公司的公共模块进行整理发布后.spring却无法扫描到相应的bean.折腾了好久,最终发现是认识上的误区. 2015-11-1 ...

  9. iOS7 中的JavaScriptCore简单介绍

    以前写过一篇介绍如何使用第三方库在ios上进行js和oc交互调用的文章,链接如下 iOS 使用UIWebView把oc代码和javascript相关联.当时建立项目时,仍然是ios6时代,所以没有原生 ...

  10. Java中ArrayList的自我实现

    对于ArrayList相比大家都很熟悉,它是java中最常用的集合之一.下面就给出它的自我实现的java代码. 需要说明的一点是,它是基于数组创建的.所以它在内存中是顺序存储,对于查找十分的方便. p ...