hdu 5706 GirlCat 暴力
来源:互联网 发布:手机淘宝详情优惠券 编辑:程序博客网 时间:2024/05/17 08:32
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1020 Accepted Submission(s): 642
Problem Description
As a cute girl, Kotori likes playing ``Hide and Seek'' with cats particularly.
Under the influence of Kotori, many girls and cats are playing ``Hide and Seek'' together.
Koroti shots a photo. The size of this photo isn×m , each pixel of the photo is a character of the lowercase(from `a' to `z').
Kotori wants to know how many girls and how many cats are there in the photo.
We define a girl as -- we choose a point as the start, passing by 4 different connected points continuously, and the four characters are exactly ``girl'' in the order.
We define two girls are different if there is at least a point of the two girls are different.
We define a cat as -- we choose a point as the start, passing by 3 different connected points continuously, and the three characters are exactly ``cat'' in the order.
We define two cats are different if there is at least a point of the two cats are different.
Two points are regarded to be connected if and only if they share a common edge.
Under the influence of Kotori, many girls and cats are playing ``Hide and Seek'' together.
Koroti shots a photo. The size of this photo is
Kotori wants to know how many girls and how many cats are there in the photo.
We define a girl as -- we choose a point as the start, passing by 4 different connected points continuously, and the four characters are exactly ``girl'' in the order.
We define two girls are different if there is at least a point of the two girls are different.
We define a cat as -- we choose a point as the start, passing by 3 different connected points continuously, and the three characters are exactly ``cat'' in the order.
We define two cats are different if there is at least a point of the two cats are different.
Two points are regarded to be connected if and only if they share a common edge.
Input
The first line is an integer T which represents the case number.
As for each case, the first line are two integersn and m , which are the height and the width of the photo.
Then there aren lines followed, and there are m characters of each line, which are the the details of the photo.
It is guaranteed that:
T is about 50.
1≤n≤1000 .
1≤m≤1000 .
∑(n×m)≤2×106 .
As for each case, the first line are two integers
Then there are
It is guaranteed that:
Output
As for each case, you need to output a single line.
There should be 2 integers in the line with a blank between them representing the number of girls and cats respectively.
Please make sure that there is no extra blank.
There should be 2 integers in the line with a blank between them representing the number of girls and cats respectively.
Please make sure that there is no extra blank.
Sample Input
31 4girl2 3otocat3 4girlhrlthlca
Sample Output
1 00 24 1dfs 暴力#include<stdio.h>#include<string.h>using namespace std;char s[1003][1003];int n,m;long long G,C;int dx[4]={0,0,-1,1};int dy[4]={1,-1,0,0};int dfs(int x,int y,int pos,int F){ for(int i=0;i<4;i++) { int tx=x+dx[i]; int ty=y+dy[i]; if(tx>0&&ty>0&&tx<=n&&ty<=m) { if(F) { if(pos==1&&s[tx][ty]=='i') dfs(tx,ty,2,F); if(pos==2&&s[tx][ty]=='r') dfs(tx,ty,3,F); if(pos==3&&s[tx][ty]=='l') G++; } else { if(pos==1&&s[tx][ty]=='a') dfs(tx,ty,2,F); if(pos==2&&s[tx][ty]=='t') C++; } } }}int main(){ int T; scanf("%d",&T); while(T--) { C=0,G=0; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) scanf("%s",s[i]+1); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { //printf("%") if(s[i][j]=='g') dfs(i,j,1,1); if(s[i][j]=='c') dfs(i,j,1,0); } } printf("%lld %lld\n",G,C); }}
阅读全文
0 0
- hdu 5706 GirlCat 暴力
- hdu 5706 GirlCat【暴力DFS】
- hdu 5706 GirlCat(dfs)
- hdu 5706 GirlCat(深搜)
- HDU 5706 GirlCat
- hdu 5706 GirlCat
- hdu 5706 GirlCat(DFS)
- hdu 5706 GirlCat
- HDU 5706 GirlCat DFS解决
- HDU-5706-GirlCat【BFS】【2016CCPC女生专场】
- hdoj-5706-GirlCat
- HDU 5706 暴力dfs
- DFS-GirlCat
- HDU5706 GirlCat
- 【2016杭电女生赛1005】【暴力 bfs or dfs or 模拟】girlcat 数女生数和猫咪数
- 【字符串暴力】hdu 2847
- HDU **** 暴力模拟
- HDU-1128 暴力搜索
- 学习swoole的心得
- B. Fox Dividing Cheese----GCD/因子问题
- UVa --- 10464 Even Parity 偶数矩阵 【状态压缩 + 暴力枚举 + 思维】
- zookeeper安装及排除错误
- Hbase表属性②
- hdu 5706 GirlCat 暴力
- RH254-第二十四节-Apache服务的配置
- LeetCode (Binary Tree Right Side View)
- js组合键和单个键盘事件
- POJ 2528(线段树,区间覆盖,离散化思想)
- dfs(hdu1241)
- hdu 6034 Balala Power!
- 优秀程序员不得不知道的20个位运算技巧
- HBase分布式搭建