博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ZOJ 2067 White Rectangles
阅读量:4599 次
发布时间:2019-06-09

本文共 1796 字,大约阅读时间需要 5 分钟。

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

 

 

1 #include 
2 #include
3 int n; 4 char g[102][102]; 5 int f[102][102]; 6 7 int main(int argc, char *argv[]) 8 { 9 while( scanf("%d",&n)!=EOF ){10 for(int i=1; i<=n; i++){11 getchar();12 for(int j=1; j<=n; j++){13 scanf("%c" ,&g[i][j]);14 }15 }16 memset(f,0,sizeof(f));17 for(int i=1; i<=n; i++){18 for(int j=1; j<=n; j++){19 if(g[i][j]=='.')20 f[i][j]=f[i][j-1]+1;21 }22 }23 int ans=0;24 for(int i=1; i<=n; i++){25 for(int j=1; j<=n; j++){26 int cur=f[i][j];27 if(cur==0)continue;28 int cnt=0;29 int min=cur;30 while(cnt+i<=n){31 if(min<=0){32 break; 33 }else{34 if(f[i+cnt][j]

 

转载于:https://www.cnblogs.com/chenjianxiang/p/3616591.html

你可能感兴趣的文章
Mac下多个jdk自由切换
查看>>
Android中onInterceptTouchEvent、dispatchTouchEvent及onTouchEvent的调用顺序及内部原理
查看>>
extension(类扩展)和 category(类别)
查看>>
Swift - 跑酷游戏开发(SpriteKit游戏开发)
查看>>
iOS 8 Metal Swift教程(一) :开始学习
查看>>
List接口源码解读
查看>>
GNU Radio入门之旅
查看>>
将数据库所有表和字段首字母变成大写
查看>>
如何在vue项目中使用md5.js及base64.js
查看>>
最长公共子序列 Lcs
查看>>
关于虚拟空间上传没有权限问题 只要更改一下system.web 就可以
查看>>
C#知识点总结【1】
查看>>
BZOJ 1257: [CQOI2007]余数之和
查看>>
20155235 2016-2017-2 《Java程序设计》第六周学习总结
查看>>
H3C VLAN 配置
查看>>
BZOJ 1077: [SCOI2008]天平
查看>>
第一天
查看>>
团队冲刺第十天
查看>>
Gradle用户指南
查看>>
iOS审核策略重磅更新:Guideline 2.1批量拒审
查看>>