ZOJ 2975 Kinds of Fuwas
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu
Description
In the year 2008, the 29th Olympic Games will be held in Beijing. This will signify the prosperity of China as well as becoming a festival for people all over the world.
The official mascots of Beijing 2008 Olympic Games are Fuwa, which are named as Beibei, Jingjing, Haunhuan, Yingying and Nini. Fuwa embodies the natural characteristics of the four most popular animals in China -- Fish, Panda, Tibetan Antelope, Swallow -- and the Olympic Flame. To popularize the official mascots of Beijing 2008 Olympic Games, some volunteers make a PC game with Fuwa.
As shown in the picture, the game has a matrix of Fuwa. The player is to find out all the rectangles whose four corners have the same kind of Fuwa. You should make a program to help the player calculate how many such rectangles exist in the Fuwa matrix.
Input
Standard input will contain multiple test cases. The first line of the input is a single integer T (1 <= T <= 50) which is the number of test cases. And it will be followed by T consecutive test cases.
The first line of each test case has two integers M and N (1 <= M, N <= 250), which means the number of rows and columns of the Fuwa matrix. And then there are M lines, each has N characters, denote the matrix. The characters -- 'B' 'J' 'H' 'Y' 'N' -- each denotes one kind of Fuwa.
Output
Results should be directed to standard output. The output of each test case should be a single integer in one line, which is the number of the rectangles whose four corners have the same kind of Fuwa.
Sample Input
2
2 2
BB
BB
5 6
BJHYNB
BHBYYH
BNBYNN
JNBYNN
BHBYYH
Sample Output
1
8
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
int main()
{
int a;
cin>>a;
while(a--)
{ int n,m,t;
cin>>n>>m;
char JU[][];//输入信息
for(int i=;i<n;i++)
for(int j=;j<m;j++)
cin>>JU[i][j];
char wa[]={"BJHYN"};
int he= ;
for(int i=;i<n;i++)
for(int j=i+;j<n;j++)
{
for(int p=;p<;p++)
{
t=;
for(int l=;l<m;l++)
if(JU[i][l]==wa[p]&&JU[j][l]==wa[p])//划线……
t=t+;
he=he+t*(t-)/;//等差数列求和
}
}
printf("%d\n",he);
}
return ;
}
ZOJ 2975 Kinds of Fuwas的更多相关文章
- 哈理工2015暑假集训 zoj 2975 Kinds of Fuwas
G - Kinds of Fuwas Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Subm ...
- ZOJ 2975 Kinds of Fuwas(暴力+排列组合)
Kinds of Fuwas Time Limit: 2 Seconds Memory Limit: 65536 KB In the year 2008, the 29th Olympic ...
- ZOJ 2975 思维
题意 给出一个矩形 问在其中存在多少子矩形 其四个角上的字母是一样的 一开始暴力写了一发 先枚举行数 再枚举两个列数 再向下枚举行数 判断能否 没有意外的超时了 后来想了想 当我们已经确定两个列数的时 ...
- The 5th Zhejiang Provincial Collegiate Programming Contest------ProblemK:Kinds of Fuwas
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1974 题意:问四个角都有同一个福娃的矩形有多少个. #include<b ...
- nenu contest3 The 5th Zhejiang Provincial Collegiate Programming Contest
ZOJ Problem Set - 2965 Accurately Say "CocaCola"! http://acm.zju.edu.cn/onlinejudge/showP ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- ZOJ2975 伪数组压缩+组合数
Kinds of Fuwas Time Limit: 2 Seconds Memory Limit:65536 KB In the year 2008, the 29th Olympic G ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- QDU_组队训练(ABEFGHKL)
A - Accurately Say "CocaCola"! In a party held by CocaCola company, several students stand ...
随机推荐
- J2EE架构
从整体上讲,J2EE是使用Java技术开发企业级应用的一种事实上的工业标准(Sun公司出于其自身利益的考虑,至今没有将Java及其相关技术纳入标准化组织的体系),它是Java技术不断适应和促进企业级应 ...
- HDU 1863 畅通工程 最下生成树问题
题目描述:给出图,要你求是否存在最小生成树,如果存在,要求输出最小权值和,如果不存在,输出? 解题报告:又是一个最裸的克鲁斯卡尔,并且要判断是否存在最小生成树的问题.废话不多说,给个短代码: #inc ...
- 记关于vue-cli3 本地代理模拟数据的实践
网上说的基本都是使用express或http-server作为服务器或其它什么东西自己把玩php也有些年头,就用php好了 服务环境 apache,php先配置好隐藏php后缀扩展名: 在httpd. ...
- Java基础打包以及批处理命令运行
1.前期准备
- XSS小游戏通关Writeup
源码下载:https://files.cnblogs.com/files/nul1/xss%E7%BB%83%E4%B9%A0%E5%B0%8F%E6%B8%B8%E6%88%8F.zip 我也没啥可 ...
- 百度url解析Joe.Smith整理大全
百度url解析Joe.Smith整理大全 百度url解析Joe.Smith整理大全...1 本文链接:http://blog.csdn.net/qq_26816591/article/details/ ...
- C#使用redis学习笔记
1.官网:http://redis.io/(英) http://www.redis.cn/(中) 2.下载:https://github.com/dmajkic/redis/downloads(Wi ...
- java垃圾回收的回收器
回收器的种类: --串行(–XX:+UseSerialGC ) Out ofBox算法,年轻代串行复制,年老代串行标记整理,主要用于桌面应用 --并行(–XX:+UseParallelGC ) 年轻代 ...
- Error updating database. Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String异常处理
问题原因:Mybatis中对于时间参数进行比较时的一个BUG. 如果拿传入的时间类型参数与空字符串‘‘进行对比判断则会引发异常.,所以应该去掉该判断, 只保留非空判断就正常了 <if test= ...
- ASP .Net Core系统部署到SUSE Linux Enterprise Server 12 SP3 64 具体方案
.Net Core 部署到 SUSE Linux Enterprise Server 12 SP3 64 位中的步骤 1.安装工具 1.apache 2..Net Core(dotnet-sdk-2. ...