White Rectangles
来源:互联网 发布:广东职业继续教育网络 编辑:程序博客网 时间:2024/06/05 06:22
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
题意:地图中找出由 点 构成的矩形的个数
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define inf 0x3f3f3f3fchar a[110][110];int coun[110][110];int n;void A(){ for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { if(a[i][j]=='.') coun[i][j]=coun[i][j-1]+1; //printf("%d ",coun[i][j]); } //printf("\n");/*1 2 0 10 0 1 01 0 1 21 0 1 0*/ }}int AA(){ int ans=0; for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++)// { int m=inf; for(int l=i;l<=n&&coun[l][j]!=0;l++)//1列1列的判断,点不连续就结束 { m=min(m,coun[l][j]); ans+=m; } } } return ans;}int main(){while(scanf("%d",&n)!=EOF) { memset(coun,0,sizeof(coun)); for(int i=1;i<=n;i++) scanf("%s",a[i]+1); A(); printf("%d\n",AA()); }return 0;}
0 0
- White Rectangles
- hdu 1510 white rectangles
- ZOJ2067 White Rectangles
- White Rectangles(hdu 1510)
- zoj 2067 - White Rectangles
- 1510 White Rectangles
- ZOJ 2067 HDU 1510 White Rectangles
- ZOJ2067 White Rectangles 很好的DP递推啊
- hdu1510 White Rectangles(组合计数问题)
- Rectangles
- Rectangles
- Rectangles
- Rectangles
- Rectangles
- White
- 1468 Rectangles
- Rectangles dp
- Packing Rectangles
- 二维灰度直方图原理
- 51nod 1183 编辑距离(动态规划)
- 博客
- 腾讯课堂Day4作业
- 子树
- White Rectangles
- 模拟实现strstr
- MySQL的基本配置与创建数据库
- 博客
- 当点击遍历出来的图片时,如何判断改图片是被选中了,如何在其他地方获取到改图片的信息
- 数据包结构分析
- js特效05正则简介
- Java三角与倒三角菱形和空心菱形
- 对于nginx $request_time的一些理解