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 ...
随机推荐
- 勒索软件Locky、Tesalcrypt等使用了新的工具躲避检测
勒索软件Locky.Tesalcrypt等使用了新的工具躲避检测 今天我们发现Locky勒索软件家族使用一种新的工具来躲避检测,并且可能已经感染了很多节点. 自从我们通过AutoFocus智能威胁分析 ...
- Centos6.5下rsync+inotify的配置详解
Centos 6.5配置rsync+inotify实现文件实时同步 1.安装rsync(两台机器执行相同的步骤) yum install gcc yum install rsyncd xinetd - ...
- 2018-11-3& maven
https://www.cnblogs.com/clsn/p/7944116.html#auto_id_10 http://www.runoob.com/maven/maven-creating-pr ...
- AngularJS里面$emit, $broadcast,$on,$http.Jsonp,constant是使用笔记
本片主要介绍$emit, $broadcast,$on经常开发的用法!
- poj2709
模拟题,在合成灰色的时候,每次取当前剩余最多的三种颜色,各取1mL合成.然后重新看剩余最多的是哪三个. #include <cstdio> #include <cstdlib> ...
- css-实现图标在输入框中显示
一:JavaScript 是脚本语言 JavaScript 是一种轻量级的编程语言. JavaScript 是可插入 HTML 页面的编程代码. JavaScript 插入 HTML 页面后,可由所有 ...
- Android 常用动画之RotateAnimation
前两天接到任务做一个UI,有用到动画,于是抽空看了下Android动画相关知识. Android Animation共有四大类型,分别是 Alpha 透明度动画 Scale 大小伸 ...
- 原生js实现ajax跨域(兼容IE8,IE9)
html设置meta标签兼容360兼容模式和IE怪异模式 <meta http-equiv="X-UA-Compatible" content="IE=9;IE=8 ...
- DOM文档对象模型简介
DOM简介 DOM是W3C(万维网联盟)的标准 "W3C文档对象模型DOM是中立于平台和语言的接口,它允许程序和脚本动态地访问和更新文档的内容.结构.样式".W3C DOM ...
- mysql连接池模块
如果不想程序在查询数据时卡死或等待过长时间,一般不推荐在node中开启一个连接后全部查询都用这个链接并且不关闭.因为node里面的mysql不像php里的那样会在完成查询后断开,只要不主动断开,连接一 ...