HDU 5319 Painter

HDU-5319

题意:画家每次只会画\ 或 /,并且用 R 画\ 用B 画/。如果一个点被BR都涂过,就会变成G。给出一张被画完的图,求它被画了几下。
解题思路:遇到B或G时判断它右上角是不是B或者G,如果都不是就代表要从这个点开始画一笔。R或G时判断左上角。

/*************************************************************************
    > File Name: 0722e.cpp
    > Author: Narsh
    > 
    > Created Time: 2016年07月22日 星期五 19时52分37秒
 ************************************************************************/

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int n,t,tot,m;
string s[300];
int main() {
    scanf("%d\n",&t);
    s[0]="                                            ";
    while (t--) {
        scanf("%d\n",&n);
        for (int i = 1; i <= n; i++)
            cin>>s[i];
        m=s[1].length();
        for (int i = 1; i <= n; i++) {
            s[i]=" "+s[i];
        //  cout<<s[i]<<endl;
        }
        tot=0;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= m; j++)
                if (s[i][j] == 'G' || s[i][j]=='R') 
                    if (!(s[i-1][j-1] == 'R' || s[i-1][j-1] == 'G')) tot++;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= m; j++)
                if (s[i][j] == 'G' || s[i][j] == 'B')
                    if (!(s[i-1][j+1] == 'B' || s[i-1][j+1] == 'G')) tot++;
        printf("%d\n",tot);
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值