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+ ...
随机推荐
- bzoj3064 CPU监控
今天终于写了一道正常的题 思路是这样的: 1.普通线段树add,set不变,并改为下放标记版本 2.past_addv 记录一个区间内可能的addv值的最大值 3.past_setv 记录一个区间被s ...
- 【LeetCode】226 - Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Notice: Goog ...
- java 抽象类和接口
接口和内部类为我们提供了一种将接口与实现分离的更加结构化的方法. 抽象类与接口是java语言中对抽象概念进行定义的两种机制,正是由于他们的存在才赋予java强大的面向对象的能力.他们两者之间对抽象概念 ...
- [POJ] #1002# 487-3279 : 桶排序/字典树(Trie树)/快速排序
一. 题目 487-3279 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 274040 Accepted: 48891 ...
- How to install php evn on ubuntu
1. How to install PHP EVN 打开终端,也就是命令提示符. 我们先来最小化组建安装,按照自己的需求一步一步装其他扩展.命令提示符输入如下命令: 1 sudo apt-get in ...
- 【多线程】Java线程面试题 Top 50(转载)
Java线程面试题 Top 50 原文链接:http://www.importnew.com/12773.html 本文由 ImportNew - 李 广 翻译自 javarevisited.欢迎 ...
- 负载均衡--大型在线系统实现的关键(上篇)(再谈QQ游戏百万人在线的技术实现)
http://blog.csdn.net/sodme/article/details/393165 —————————————————————————————————————————————— 本文作 ...
- C++ 之关联容器 map
标准库定义了四种关联容器:map是其中之一(另外还有set.multimap.multiset).map的元素以键-值(key-value),在学了顺序容器之后,再学习关联容器,就比较比较好理解了. ...
- [置顶] 2013 Multi-University Training Contest 8
1003 Mine 简单sg的博弈题,我们走入了nim博弈的误区,后来发现改了三四个字符就过了....我只能说我是sbsbsbsbsbsb...判奇偶啊... #pragma comment(link ...
- HDU 5444 Elven Postman (二叉树,暴力搜索)
题意:给出一颗二叉树的先序遍历,默认的中序遍历是1..2.……n.给出q个询问,询问从根节点出发到某个点的路径. 析:本来以为是要建树的,一想,原来不用,其实它给的数是按顺序给的,只要搜结点就行,从根 ...