Submission #64255

#TimeUsernameProblemLanguageResultExecution timeMemory
64255keko37Dango Maker (JOI18_dango_maker)C++14
13 / 100
3 ms748 KiB
#include<iostream>

using namespace std;

const int MAXN = 3005;

int n, m, a, b, sol;
char l[MAXN] [MAXN];
int bio[MAXN] [MAXN];

bool ok (int x, int y, int d) {
	if (d == 0) {
		return l[x] [y] == 'R' && l[x+1] [y] == 'G' && l[x+2] [y] == 'W';
	} else {
		return l[x] [y] == 'R' && l[x] [y+1] == 'G' && l[x] [y+2] == 'W';
	}
}

void dfs (int x, int y) {
	if (bio[x] [y]) return;
	bio[x] [y] = 1;
	int cnt = 0;
	if (ok(x, y, 0)) a++;
	if (ok(x, y, 1)) b++, cnt++;
	if (cnt) {
		if (x-1 >= 0) dfs(x-1, y+1);
		if (x-2 >= 0) dfs(x-2, y+2);
	}
}

int main () {
	cin >> n >> m;
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			cin >> l[i] [j];
		}
	}
	for (int i=n-1; i>=0; i--) {
		for (int j=m-1; j>=0; j--) {
			if (!bio[i] [j]) {
				a = b = 0;
				dfs(i, j);
				sol += max(a, b);
			}
		}
	}
	cout << sol;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...