toj3857. Jiong

来源:互联网 发布:iphone实用软件排行 编辑:程序博客网 时间:2024/06/05 23:42

其实题目略水,但看起来有点怕
然后当\不能被系统识别时,可以在其前面再加一个\
思路便是先把jiong用数组存起来,然后进行枚举

#include <map>#include <set>#include <stack>#include <queue>#include <cmath>#include <ctime>#include <vector>#include <cstdio>#include <cctype>#include <cstring>#include <cstdlib>#include <iostream>#include <algorithm>using namespace std;#define INF 0x3f3f3f3f#define inf -0x3f3f3f3f#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define mem0(a) memset(a,0,sizeof(a))#define mem1(a) memset(a,-1,sizeof(a))#define mem(a, b) memset(a, b, sizeof(a))typedef long long ll;const int N=5;const int maxn=55;const int M=10+1;char jiong[N][M]={    "+--------+",    "| /    \\ |",    "|/ +--+ \\|",    "|  |  |  |",    "+--+--+--+"};char mp[maxn][maxn];int solve(int x,int y){    for(int i=x;i<x+5;i++)        for(int j=y;j<y+10;j++){            if(mp[i][j]!=jiong[i-x][j-y])                return 0;        }    return 1;}int main(){    int n,m;    while(scanf("%d%d",&n,&m)==2){        for(int i=0;i<n;i++){            getchar();            for(int j=0;j<m;j++)                scanf("%c",&mp[i][j]);        }/*      for(int i=0;i<n;i++){            for(int j=0;j<m;j++){                cout<<mp[i][j];            }               cout<<endl;        } */        int cnt=0;        for(int i=0;i<=n-N;i++)            for(int j=0;j<=m-10;j++){                if(solve(i,j))                    cnt++;            }        printf("%d\n",cnt);    }    return 0;}
0 0