Face Detection
来源:互联网 发布:哪个数据库有引文检索 编辑:程序博客网 时间:2024/06/11 20:05
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 a2 × 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 andm (1 ≤ n, m ≤ 50) — the height and the width of the image, respectively.
Next n lines define the image. Each line containsm lowercase Latin letters.
Output
In the single line print the number of faces on the image.
Sample Input
4 4xxxxxfaxxcexxxxx
1
4 2xxcfaexx
1
2 3faccef
2
1 4face
0
Sample Output
Hint
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.
#include <stdio.h>#include <stdlib.h>int main(){ int n, m, i, j, x = 0, s1 = 0, s2 = 0, s3 = 0, s4 = 0, s = 0; char a[100][100]; scanf("%d%d", &n, &m); getchar(); for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { scanf("%c", &a[i][j]); } getchar(); } for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { s1 = 0; s2 = 0; s3 = 0; s4 = 0; if (a[i][j] == 'f' || a[i][j + 1] == 'f' || a[i + 1][j] == 'f' || a[i + 1][j + 1] == 'f' && i + 1 < n && j + 1 < m) { s1++; } if (a[i][j] == 'a' || a[i][j + 1] == 'a' || a[i + 1][j] == 'a' || a[i + 1][j + 1] == 'a' && i + 1 < n && j + 1 < m) { s2++; } if (a[i][j] == 'c' || a[i][j + 1] == 'c' || a[i + 1][j] == 'c' || a[i + 1][j + 1] == 'c' && i + 1 < n && j + 1 < m) { s3++; } if (a[i][j] == 'e' || a[i][j + 1] == 'e' || a[i + 1][j] == 'e' || a[i + 1][j + 1] == 'e' && i + 1 < n && j + 1 < m) { s4++; } if (s1 > 0 && s2 > 0 && s3 > 0 && s4 > 0) s++; } } printf("%d\n", s); return 0;}
- face-detection
- Face Detection
- Face Detection
- Face Detection
- Face Detection
- Face Detection
- Week 8: Face Detection
- Android 4.0 Face Detection
- Camera Face Detection
- Face detection using HTML5
- Face Detection Matlab Code
- Camera Face Detection
- OpenCV android face detection
- A. Face Detection
- python opencv face detection
- Face Detection & Alignment
- Capture - Face detection
- face detection and aligh
- spring注解-@Component(不推荐使用)、@Repository、@Service、@Controller
- SQlite3基本语法及常用方法(API)
- PAT (Basic Level)1023. 组个最小数
- View中layout(int l, int t, int r, int b)方法的理解
- 深入剖析Java中的装箱和拆箱
- Face Detection
- Oracle中作业(jobs)定时的调用
- NSNotificationCenter 深入使用
- 安装oracle10笔记
- 傻瓜学算法系列之排序——1.冒泡排序
- 这是第一篇博客
- Two Substrings
- SQL的优化整理以及时间信息(持续更新)+ 中级以上sql
- 手把手教会你搭建Android SDK环境与下载SDK包