ACM: 简单DP 动态规划题 toj 1547
来源:互联网 发布:淘宝网左轮吉他直播 编辑:程序博客网 时间:2024/05/22 06:09
Kinds of Fuwas
描述
In the year 2008, the 29thOlympic Games will be held in Beijing. This will signify theprosperity of China as well as becoming a festival for people allover 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 popularanimals in China -- Fish, Panda, Tibetan Antelope, Swallow -- andthe Olympic Flame. To popularize the official mascots of Beijing2008 Olympic Games, some volunteers make a PC game with Fuwa.
As shown in the picture, the game has a matrix of Fuwa. Theplayer is to find out all the rectangles whose four corners havethe same kind of Fuwa. You should make a program to help the playercalculate how many such rectangles exist in the Fuwa matrix.
输入
Standard input willcontain multiple test cases. The first line of the input is asingle integer T (1 <= T<= 50) which is the number of test cases. And itwill be followed by T consecutive test cases.
The first line of each test case has two integers M andN (1 <= M, N <=250), which means the number of rows and columns of the Fuwamatrix. And then there are M lines, each has Ncharacters, denote the matrix. The characters -- 'B' 'J' 'H' 'Y''N' -- each denotes one kind of Fuwa.
输出
Resultsshould be directed to standard output. The output of each test caseshould be a single integer in one line, which is the number of therectangles whose four corners have the same kind ofFuwa.
样例输入
2
2 2
BB
BB
5 6
BJHYNB
BHBYYH
BNBYNN
JNBYNN
BHBYYH
样例输出
1
8
题意:
解题思路:
代码:
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 255
char g[MAX][MAX];
{
}
{
//
}
- ACM: 简单DP 动态规划题 toj 1547
- ACM: 简单 动态规划题 toj 1509 (…
- ACM: 动态规划题+剪枝 toj 3904
- ACM: 动态规划题 toj 1072
- ACM: 动态规划题 toj 1508
- ACM: 动态规划题 toj 1511
- ACM: 动态规划题 toj 1545
- ACM: 动态规划体 toj 1408
- ACM: 背包问题 动态规划题 toj 133…
- ACM: 0-1背包变形 动态规划题 toj …
- ACM: 简单动态规划题 poj 2955
- ACM: dp动态规划题(难) poj 3267 …
- ACM: dp题(动态规划) poj 2151 (d…
- ACM: 树状DP 动态规划题 poj 1463 …
- ACM: 动态规划题 poj 2057 树状DP
- ACM: DP训练好题 动态规划题 poj 1…
- ACM: DP+floyd 动态规划题 poj 117…
- ACM: 概率DP 动态规划题 poj 1322
- ACM: 无向图的强连通分量 图论题 p…
- ACM: 浙江省赛题目 22:00 ~ 3:00 (…
- 2012年广东ACM省赛赛后总结
- ACM: 动态规划题 toj 1511
- ACM: 动态规划题 toj 1545
- ACM: 简单DP 动态规划题 toj 1547
- ACM: DP训练好题 动态规划题 poj 1…
- ACM: 0-1背包变形 动态规划题 toj …
- ACM: 任意进制的小数转化 高精度题…
- ACM: n!末尾0的个数 数论题 poj 14…
- ACM: 扩展欧几里德+欧拉函数 数论…
- ACM: 三分法 poj 1018 (学习到三…
- cug1702&&CCNU校赛J题 分块
- ACM: 贪心题 poj 1083