A. Face Detection

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/549/problem/A

Description

The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them.

In this problem an image is a rectangular table that consists of lowercase Latin letters. A face on the image is a 2 × 2 square, such that from the four letters of this square you can make word "face".

You need to write a program that determines the number of faces on the image. The squares that correspond to the faces can overlap.

Input

The first line contains two space-separated integers, n and m (1 ≤ n, m ≤ 50) — the height and the width of the image, respectively.

Next n lines define the image. Each line contains m lowercase Latin letters.

Output

In the single line print the number of faces on the image

Sample Input

4 4
xxxx
xfax
xcex
xxxx

Sample Output

1

HINT

题意

给你n*m的格子,格子里面有字符串,然后问你有多少个2*2的格子里面,含有face

题解:

随便产生一组全排列,然后枚举就好了

代码:

  1. //qscqesze
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <ctime>
  6. #include <iostream>
  7. #include <algorithm>
  8. #include <set>
  9. #include <vector>
  10. #include <sstream>
  11. #include <queue>
  12. #include <typeinfo>
  13. #include <fstream>
  14. #include <map>
  15. #include <stack>
  16. typedef long long ll;
  17. using namespace std;
  18. //freopen("D.in","r",stdin);
  19. //freopen("D.out","w",stdout);
  20. #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
  21. #define test freopen("test.txt","r",stdin)
  22. #define maxn 2000001
  23. #define mod 10007
  24. #define eps 1e-9
  25. int Num;
  26. char CH[];
  27. const int inf=0x3f3f3f3f;
  28. const ll infll = 0x3f3f3f3f3f3f3f3fLL;
  29. inline ll read()
  30. {
  31. ll x=,f=;char ch=getchar();
  32. while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
  33. while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
  34. return x*f;
  35. }
  36. inline void P(int x)
  37. {
  38. Num=;if(!x){putchar('');puts("");return;}
  39. while(x>)CH[++Num]=x%,x/=;
  40. while(Num)putchar(CH[Num--]+);
  41. puts("");
  42. }
  43. //**************************************************************************************
  44.  
  45. string s[];
  46. string s1;
  47. int c[]={,,,};
  48. vector<int> a[];
  49. void unit()
  50. {
  51. int i = ;
  52. do
  53. {
  54. for(int j = ; j < ; j++)
  55. a[i].push_back(c[j]);
  56. i++;
  57. } while(next_permutation(c,c + ));
  58. }
  59. int main()
  60. {
  61. //test;
  62. unit;
  63. int n=read(),m=read();
  64. for(int i=;i<n;i++)
  65. cin>>s[i];
  66. s1="face";
  67. int ans=;
  68. int c[]={,,,};
  69. for(int i=;i<n-;i++)
  70. {
  71. for(int j=;j<m-;j++)
  72. {
  73. c[]=,c[]=,c[]=,c[]=;
  74. do{
  75. if(s[i][j]==s1[c[]]&&s[i+][j]==s1[c[]]&&s[i+][j+]==s1[c[]]&&s[i][j+]==s1[c[]])
  76. {
  77. ans++;
  78. break;
  79. }
  80. }while(next_permutation(c,c+));
  81. }
  82. }
  83. cout<<ans<<endl;
  84. }

The first line contains two space-separated integers, n and m (1 ≤ n, m ≤ 50) — the height and the width of the image, respectively.

Next n lines define the image. Each line contains m lowercase Latin letters.

Looksery Cup 2015 A. Face Detection 水题的更多相关文章

  1. Looksery Cup 2015

    A题水 C题 博弈论,如果不是CF有WA具体哪个点错了和数据的话,AC要难许多. 如果D的操作数大于奇数个数直接Win 偶数个数大于等于n – k 时,S直接Win 偶数个数小于n – k时,若D操作 ...

  2. Looksery Cup 2015 Editorial

    下面是题解,做的不好.下一步的目标是rating涨到 1800,没打过几次cf A. Face Detection Author: Monyura One should iterate through ...

  3. Looksery Cup 2015 B. Looksery Party 暴力

    B. Looksery Party Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/pro ...

  4. codeforces Looksery Cup 2015 D. Haar Features

    The first algorithm for detecting a face on the image working in realtime was developed by Paul Viol ...

  5. codeforces Looksery Cup 2015 C. The Game Of Parity

    There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play t ...

  6. Looksery Cup 2015 D. Haar Features 暴力

    D. Haar Features Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/prob ...

  7. Looksery Cup 2015 H. Degenerate Matrix 数学

    H. Degenerate Matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/ ...

  8. Codeforces-8VC Venture Cup 2016-Elimination Round-626A.暴力 626B.水题 626C.二分

    A. Robot Sequence time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  9. Looksery Cup 2015 F - Yura and Developers 单调栈+启发式合并

    F - Yura and Developers 第一次知道单调栈搞出来的区间也能启发式合并... 你把它想想成一个树的形式, 可以发现确实可以启发式合并. #include<bits/stdc+ ...

随机推荐

  1. HDU5807 Keep In Touch (BestCoder Round #86 D ) 分布式dp

    #include <cstdio> #include <cstring> #include <cmath> #include <vector> #inc ...

  2. map使用.xml

    map 是一种关联容器,  提供一对一的关联, 关联的形式为: KEY----VALUE     关键字不重复.multimap与map类似,但是允许关键字重复           即:关键字和与之对 ...

  3. 运算符重载 C++ 编程思想

    class Integer{ int i; public: Integer(int ii) : i(ii) {} const Integer operator+(const Integer& ...

  4. JQuery中的事件以及动画

    .bind事件 <script src="script/jquery-1.7.1.min.js"></script> <script> $(fu ...

  5. .hpp文件

    hpp在C++中的含义 以前在开源代码里面遇到过,今天看boost源码的时候又遇到了,故学习一下. hPP,计算机术语,用C/C++语言编写的头文件,通常用来定义数据类型,声明变量.函数.结构和类.而 ...

  6. ZOJ-3349 Special Subsequence 线段树优化DP

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3349 题意:给定一个数列,序列A是一个满足|Ai-Ai-1| & ...

  7. HDU-3874 Necklace 线段树+离线

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3874 比较简单的题,题意也好懂. 先O(n)求每个数左边第一次出现的与他相同的数的位置l[i].对询问 ...

  8. 怎么从sqlserver 数据库导出 insert 的数据语句

    In SSMS in the Object Explorer, right click on the database right-click and pick "Tasks" a ...

  9. [转]比较 Rational Unified Process (RUP) 和 Microsoft Solutions Framework (MSF)

      文档选项 将此页作为电子邮件发送 级别: 初级 Sandra Sergi Santos, 软件工程专家, IBM 2007 年 6 月 15 日 本文来自于 Rational Edge:Micro ...

  10. 二、 C#调用存储过程

    个人比较喜欢使用第二种传递参数的方法 1. 调用的方法 public DataTable ExceStoredProcedure (string strCom, SqlParameter[] comm ...