您的位置:首页 > 大数据 > 人工智能

HDU 5319 Painter

2016-07-23 16:13 411 查看

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);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: