标签:
http://acm.hdu.edu.cn/showproblem.php?pid=5319
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 956 Accepted Submission(s): 435
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 55; int N,m; char G[maxn][maxn]; bool check(char a, char b) { if(a == b || a == ‘G‘) return true; else return false; } int solve() { int ret = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < m; j++) { if (check(G[i][j], ‘R‘) && !check(G[i-1][j-1], ‘R‘)) ret++; if (check(G[i][j], ‘B‘) && !check(G[i-1][j+1], ‘B‘)) ret++; } } return ret; } int main () { int cas; scanf("%d", &cas); while(cas--) { scanf("%d", &N); memset(G, 0, sizeof(G)); for (int i = 0; i < N; i++) scanf("%s", G[i]); m = strlen(G[0]) ; printf("%d\n", solve()); } return 0; }
标签:
原文地址:http://www.cnblogs.com/cancangood/p/4693820.html