Looksery Cup 2015 A. Face Detection 水题
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
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
题解:
随便产生一组全排列,然后枚举就好了
代码:
- //qscqesze
- #include <cstdio>
- #include <cmath>
- #include <cstring>
- #include <ctime>
- #include <iostream>
- #include <algorithm>
- #include <set>
- #include <vector>
- #include <sstream>
- #include <queue>
- #include <typeinfo>
- #include <fstream>
- #include <map>
- #include <stack>
- typedef long long ll;
- using namespace std;
- //freopen("D.in","r",stdin);
- //freopen("D.out","w",stdout);
- #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
- #define test freopen("test.txt","r",stdin)
- #define maxn 2000001
- #define mod 10007
- #define eps 1e-9
- int Num;
- char CH[];
- const int inf=0x3f3f3f3f;
- const ll infll = 0x3f3f3f3f3f3f3f3fLL;
- inline ll read()
- {
- ll x=,f=;char ch=getchar();
- while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
- while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
- return x*f;
- }
- inline void P(int x)
- {
- Num=;if(!x){putchar('');puts("");return;}
- while(x>)CH[++Num]=x%,x/=;
- while(Num)putchar(CH[Num--]+);
- puts("");
- }
- //**************************************************************************************
- string s[];
- string s1;
- int c[]={,,,};
- vector<int> a[];
- void unit()
- {
- int i = ;
- do
- {
- for(int j = ; j < ; j++)
- a[i].push_back(c[j]);
- i++;
- } while(next_permutation(c,c + ));
- }
- int main()
- {
- //test;
- unit;
- int n=read(),m=read();
- for(int i=;i<n;i++)
- cin>>s[i];
- s1="face";
- int ans=;
- int c[]={,,,};
- for(int i=;i<n-;i++)
- {
- for(int j=;j<m-;j++)
- {
- c[]=,c[]=,c[]=,c[]=;
- do{
- if(s[i][j]==s1[c[]]&&s[i+][j]==s1[c[]]&&s[i+][j+]==s1[c[]]&&s[i][j+]==s1[c[]])
- {
- ans++;
- break;
- }
- }while(next_permutation(c,c+));
- }
- }
- cout<<ans<<endl;
- }
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 水题的更多相关文章
- Looksery Cup 2015
A题水 C题 博弈论,如果不是CF有WA具体哪个点错了和数据的话,AC要难许多. 如果D的操作数大于奇数个数直接Win 偶数个数大于等于n – k 时,S直接Win 偶数个数小于n – k时,若D操作 ...
- Looksery Cup 2015 Editorial
下面是题解,做的不好.下一步的目标是rating涨到 1800,没打过几次cf A. Face Detection Author: Monyura One should iterate through ...
- Looksery Cup 2015 B. Looksery Party 暴力
B. Looksery Party Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/pro ...
- 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 ...
- 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 ...
- Looksery Cup 2015 D. Haar Features 暴力
D. Haar Features Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/prob ...
- Looksery Cup 2015 H. Degenerate Matrix 数学
H. Degenerate Matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/ ...
- 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 ...
- Looksery Cup 2015 F - Yura and Developers 单调栈+启发式合并
F - Yura and Developers 第一次知道单调栈搞出来的区间也能启发式合并... 你把它想想成一个树的形式, 可以发现确实可以启发式合并. #include<bits/stdc+ ...
随机推荐
- HDU5807 Keep In Touch (BestCoder Round #86 D ) 分布式dp
#include <cstdio> #include <cstring> #include <cmath> #include <vector> #inc ...
- map使用.xml
map 是一种关联容器, 提供一对一的关联, 关联的形式为: KEY----VALUE 关键字不重复.multimap与map类似,但是允许关键字重复 即:关键字和与之对 ...
- 运算符重载 C++ 编程思想
class Integer{ int i; public: Integer(int ii) : i(ii) {} const Integer operator+(const Integer& ...
- JQuery中的事件以及动画
.bind事件 <script src="script/jquery-1.7.1.min.js"></script> <script> $(fu ...
- .hpp文件
hpp在C++中的含义 以前在开源代码里面遇到过,今天看boost源码的时候又遇到了,故学习一下. hPP,计算机术语,用C/C++语言编写的头文件,通常用来定义数据类型,声明变量.函数.结构和类.而 ...
- ZOJ-3349 Special Subsequence 线段树优化DP
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3349 题意:给定一个数列,序列A是一个满足|Ai-Ai-1| & ...
- HDU-3874 Necklace 线段树+离线
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3874 比较简单的题,题意也好懂. 先O(n)求每个数左边第一次出现的与他相同的数的位置l[i].对询问 ...
- 怎么从sqlserver 数据库导出 insert 的数据语句
In SSMS in the Object Explorer, right click on the database right-click and pick "Tasks" a ...
- [转]比较 Rational Unified Process (RUP) 和 Microsoft Solutions Framework (MSF)
文档选项 将此页作为电子邮件发送 级别: 初级 Sandra Sergi Santos, 软件工程专家, IBM 2007 年 6 月 15 日 本文来自于 Rational Edge:Micro ...
- 二、 C#调用存储过程
个人比较喜欢使用第二种传递参数的方法 1. 调用的方法 public DataTable ExceStoredProcedure (string strCom, SqlParameter[] comm ...