ZCMU-1927: 签到题 =。=

emmmm这道题有点坑人····

题目

1927: 签到题 =。=

Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 74 Solved: 29
[Submit][Status][Web Board]
Description

In a BG (dinner gathering) for ZCMU ACM team, the coaches wanted to count the number of people present at the BG. They did that by having the waitress take a photo for them. Everyone in the photo, no one is blocked by others. Each person in the photo has the same posture. After some preprocessing, the photo was converted into a H×W character matrix, Thus a person in this photo is represented by the diagram in the following three lines:
.O.
/|
(.)
Given the character matrix, the coaches want you to count the number of people in the photo. Note that if something is partly blocked in the photo, only part of the above diagram will be presented in the character matrix,good luck to you.
Input

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

The first contains two integers H, W (1 ≤ H, W ≤ 100) - as described above, followed by H lines, showing the matrix representation of the photo.

Output

For each test case, there should be a single line, containing an integer indicating the number of people from the photo.
Sample Input

1
3 3
.O.
/|\
(.)

Sample Output

1

题目意思就是从给的矩阵里找人···没什么思想,就是要注意没有那个点···

AC代码

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define pre(i,a,b) for(int i=a;i>=b;--i)
#define m(x) memset(x,0,sizeof x);
#define ll long long
const int maxn = 1050;
const int N = 1000;
char mp[105][105];
int n,m;
int check()
{
    int sum = 0;
    for(int i=0;i<n;++i)
    for(int j=0;j<m;++j){
        if(mp[i][j]=='O'){
            if(i+2<n&&j-1>=0&&j+1<m)
                if(mp[i+1][j]=='|'&&mp[i+1][j-1]=='/'&&mp[i+1][j+1]=='\\'&&mp[i+2][j-1]=='('&&mp[i+2][j+1]==')')
                    sum ++;
        }
        
        
    }
    return sum;
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--){
    scanf("%d%d",&n,&m);
        m(mp);
        for(int i=0;i<n;i++)cin >> mp[i];
        printf("%d\n",check());
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值