Looksery Cup 2015--aface Detection

Source: Internet
Author: User

The developers of Looksery has to write a efficient algorithm, detects faces on a picture. Unfortunately, they is currently busy preparing a contest for your, so you'll have the to does 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 can make word "face".

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

Input

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

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

Output

The the single line print the number of faces on the image.

Sample Test (s) input
4 4
Xxxx
Xfax
Xcex
Xxxx
Output
1
Input
4 2
Xx
Cf
Ae
Xx
Output
1
Input
2 3
Fac
Cef
Output
2
Input
1 4
Face
Output
0
Note

In the first sample of the image contains a single face, located in a square with the upper left corner at the second d The second column:

In the second sample of the image also contains exactly one face, it upper left corner are at the second row and the first Co Lumn.

In the third sample faces is shown:

The fourth sample the image has a no faces on it.

#include <cstdio> #include <cstring> #include <algorithm>int main () {int N,m;int C[55][55];char  A [55] [55];while (~SCANF ("%d%d", &n,&m)) {int count = 0;memset (c,0,sizeof (c)); GetChar (); for (int i = 1; I <= n; i++) {fo R (Int j = 1; j <= M; j + +) scanf ("%c", &a[i][j]); GetChar ();}    for (int i = 1, i <= N; i++) {for (int j = 1; j <= M; j + +) {if (a[i][j] = = ' F ') c[i][j] = 1;if (a[i][j] = = ' a ') c[i][j] = 10;if (a[i][j] = = ' C ') c[i][j] = 100;if (a[i][j] = = ' E ') c[i][j] = 1000;}} for (int i = 1; I <= n; i++) {//for (int j = 1; j <= M; j + +) {//printf ("%c", A[i][j]);//}//puts ("");//}//for (int i = 1; I <= N; i++) {//for (int j = 1; j <= M; j + +)//printf ("%d", c[i][j]);//puts ("");//}for (int i = 1; I < n; i++) {for (int j = 1; j < M; J + +) {if (C[i][j] + c[i+1][j+1] + c[i+1][j] + c[i][j+1] = = 1111) count++;}} printf ("%d\n", count);} return 0;}

  

Looksery Cup 2015--aface Detection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.