Submission #1234889

#TimeUsernameProblemLanguageResultExecution timeMemory
1234889gry3125Dango Maker (JOI18_dango_maker)C++20
13 / 100
2095 ms412 KiB
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define fi first
#define se second
using namespace std;

char a[20][20];
bool b[20][20];
int n, m, mx = 0;

void dfs(int i, int j) {
	if (i == n) {i = 0; j++;}
	if (j == m) {
		int cnt = 0;
		for (int ii = 0; ii < n; ii++) {
			for (int jj = 0; jj < m; jj++) {
				if (b[ii][jj]) cnt++;
			}
		}
		cnt /= 3;
		mx = max(mx, cnt); return;
	}
	
	if (a[i][j] == 'R' && a[i+1][j] == 'G' && a[i+2][j] == 'W') {
		if (!b[i][j] && !b[i+1][j] && !b[i+2][j]) {
			b[i][j] = 1; b[i+1][j] = 1; b[i+2][j] = 1; 
			dfs(i+1, j);
			b[i][j] = 0; b[i+1][j] = 0; b[i+2][j] = 0;
		}
	}
	if (a[i][j] == 'R' && a[i][j+1] == 'G' && a[i][j+2] == 'W') {
		if (!b[i][j] && !b[i][j+1] && !b[i][j+2]) {
			b[i][j] = 1; b[i][j+1] = 1; b[i][j+2] = 1; 
			dfs(i+1, j);
			b[i][j] = 0; b[i][j+1] = 0; b[i][j+2] = 0; 
		}
	}
	dfs(i+1, j);
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < 20; i++) {
		for (int j = 0; j < 20; j++) {
			a[i][j] = '.';
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	dfs(0, 0);
	cout << mx;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...