A. Face Detection
来源:互联网 发布:淘宝开通信用卡 编辑:程序博客网 时间:2024/04/29 20:15
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 × 2square, 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.
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.
In the single line print the number of faces on the image.
4 4xxxxxfaxxcexxxxx
1
4 2xxcfaexx
1
2 3faccef
2
1 4face
0
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.
解题说明:此题是一道图形题,要求找出图中所有包含F‘a’c‘e这四个字母的2*2的矩形。最简单的方法是暴力穷举,遍历整个图,然后进行判断统计。注意边界情况即可。
#include <stdio.h>int n,m,i,j,t,d1,d2,d3,d4,k,l;char a[105][105];int main(){scanf("%d%d",&n,&m);for(i=0;i<n;i++){scanf("%s",a[i]);}for(i=0;i<n-1;i++){for(j=0;j<m-1;j++){d1=d2=d3=d4=0;for(k=0;k<2;k++){for(l=0;l<2;l++){if(a[i+k][j+l]=='f'){d1=1;}if(a[i+k][j+l]=='a'){d2=1;}if(a[i+k][j+l]=='c'){d3=1;}if(a[i+k][j+l]=='e'){d4=1;}}}if(d1&&d2&&d3&&d4){t++;}}}printf("%d\n",t);return 0;}
- A. Face Detection
- coderforce 549A Face Detection
- codeforces 549A Face Detection
- Looksery Cup 2015 A. Face Detection
- Looksery Cup 2015 A. Face Detection
- 【数据集】A Face Detection Benchmark
- CodeForces NO.549A Face Detection
- Performing Face Detection on a video
- face-detection
- Face Detection
- Face Detection
- Face Detection
- Face Detection
- Face Detection
- 论文《A Convolutional Neural Network Cascade for Face Detection》笔记
- [文献阅读]A Convolutional Neural Network Cascade for Face Detection
- 【论文笔记】A Convolutional Neural Network Cascade for Face Detection
- 论文《A Convolutional Neural Network Cascade for Face Detection》笔记
- linux ssh port forward
- UGUI - 关于ScrollContent 和 Grid使用
- 东大OJ-1588: Routing Table
- git 2.4.3 dependencies install
- iOS不同版本适配问题(#ifdef __IPHONE_7_0)
- A. Face Detection
- 用百度SDK获取地理位置和天气信息
- iOS 数据的本地存储-自定义对象的归档
- 设置textview中hint的大小
- 斗鱼TV协议分享
- 关于Solr的基本概念
- fpxswallowmachinEmacs2015
- 显示、隐藏软键盘的硬方法
- Android 媒体文件管理