A. Face Detection
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Examples
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 the image contains a single face, located in a square with the upper left corner at the second line and the second column:

In the second sample the image also contains exactly one face, its upper left corner is at the second row and the first column.

In the third sample two faces are shown:

In the fourth sample the image has no faces on it.


题意:四个格子里出现face四个字母


我是用了个vis数组,题解是给四个格子字母排序与acef对比

//
// main.cpp
// cf549a
//
// Created by Candy on 9/15/16.
// Copyright © 2016 Candy. All rights reserved.
// #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int N=;
int n,m,ans=;
int a[N][N],vis[];
char s[N];
int main(int argc, const char * argv[]) {
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++){
scanf("%s",s);
for(int j=;j<m;j++)
a[i][j+]=s[j]-'a';
} for(int i=;i<=n-;i++)
for(int j=;j<=m-;j++){
memset(vis,,sizeof(vis));
vis[a[i][j]]++;
vis[a[i+][j]]++;
vis[a[i][j+]]++;
vis[a[i+][j+]]++;
if(vis[]&&vis['f'-'a']&&vis['c'-'a']&&vis['e'-'a']) ans++;
}
printf("%d",ans);
return ;
}
 

Codeforces 549A. Face Detection[模拟]的更多相关文章

  1. Codeforces 738D. Sea Battle 模拟

    D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard inp ...

  2. Codeforces 626A Robot Sequence(模拟)

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

  3. CodeForces - 589D(暴力+模拟)

    题目链接:http://codeforces.com/problemset/problem/589/D 题目大意:给出n个人行走的开始时刻,开始时间和结束时间,求每个人分别能跟多少人相遇打招呼(每两人 ...

  4. Codeforces 767B. The Queue 模拟题

    B. The Queue time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...

  5. Codeforces 704A Thor 队列模拟

    题目大意:托尔有一部手机可执行三种操作 1.x APP产生一个新消息 2.读取x App已产生的所有消息 3.读取前t个产生的消息 问每次操作后未读取的消息的数量 题目思路: 队列模拟,坑点在于竟然卡 ...

  6. Vasya And The Mushrooms CodeForces - 1016C (前缀和模拟)

    大意: 给定2*n的矩阵, 每个格子有权值, 走到一个格子的贡献为之前走的步数*权值, 每个格子只能走一次, 求走完所有格子最大贡献. 沙茶模拟打了一个小时总算打出来了 #include <io ...

  7. Codeforces 691C. Exponential notation 模拟题

    C. Exponential notation time limit per test: 2 seconds memory limit per test:256 megabytes input: st ...

  8. Codeforces 658A. Robbers' watch 模拟

    A. Robbers' watch time limit per test: 2 seconds memory limit per test: 256 megabytes input: standar ...

  9. Codeforces 438D (今日gg模拟第二题) | 线段树 考察时间复杂度的计算 -_-|||

    Codeforces 438D The Child and Sequence 给出一个序列,进行如下三种操作: 区间求和 区间每个数模x 单点修改 如果没有第二个操作的话,就是一棵简单的线段树.那么如 ...

随机推荐

  1. go语言 新手学习笔记 go基础教程

    目前这方面的资料相对较少,自己手动整理汇集. 第一章:安装 第一节:下载go语言 第二节:windows 安装 go语言 第三节: 第二章:基本语法 第一节:类型 .

  2. 【Bootstrap】4.企业网站(待续)

    上一章有队个人站点站点进行一些优化.本章,轮到我们充实这个作品站点了,补充一些项目,从而展示我们的能力.话句话说,我们要构建一个相对复杂的企业网站主页. 下面有几个成功企业的网站: □ Zappos ...

  3. 学习zepto.js(原型方法)[1]

    新的一周,新的开始,今天来学习一下zepto里边的原型方法,就是通过$.进行调用的方法,也是可以通过$.fn进行扩展的方法: $.camelCase(): 方法接收一个字符串,将连字符格式的字符串转为 ...

  4. ubuntu 搭建开发环境

    一. 安装C/C++程序的开发环境 1. sudo apt-get install build-essential //安装主要编译工具 gcc, g++, make 2. sudo apt-get ...

  5. [outlook]打开以后就自动进入安全模式的解决方法。Outlook start in safe mode.

    给客户写了一个Outlook的add-in, 用现在时髦的话应该叫outlook的app. 这个add-in的作用就是把outlook中的email,直接上传到SharePoint中.想要代码的联系我 ...

  6. Autodesk 招人了,开发顾问,感兴趣的或者有推荐的人扔简历过来啊

    Autodesk ADN招人了,在上海,开发顾问, JD如下. 如果你感兴趣或者有人推荐,扔简历过来啊, daniel.du@autodesk.com,赶早不赶晚啊.   Job Title: Dev ...

  7. VMware: XXX is still busy. Please wait until the operation is complete before closing

      在使用vmware的过程中发现创建快照.恢复快照.管理快照等功能突然都变成灰色的,用不了.更觉得夸张的是仅仅剩下关闭虚机按钮是红色的.心想估计是虚机快照没处理完之类的问题导致的,于是想想关闭虚机重 ...

  8. 设置 Xcode 自动生成代码片段

    一.什么是代码片段 当在Xcode中输入dowhile并回车后,Xcode会出现下图所示的提示代码: 这就是代码片段,目的是使程序员以最快的速度输入常用的代码片段,提高编程效率.该功能是从Xcode4 ...

  9. iOS启动过程

    1.main函数 | 2.UIApplicationMain      * 创建UIApplication对象      * 创建UIApplication的delegate对象 | 3.delega ...

  10. Android 视频播放器进度的处理

    在前面的项目中添加SeekBar <SeekBar android:id="@+id/sb" android:layout_width="match_parent& ...