Submission #332521

#TimeUsernameProblemLanguageResultExecution timeMemory
332521limabeansDango Maker (JOI18_dango_maker)C++17
13 / 100
2091 ms620 KiB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl











const int maxn = 3002;


int n, m;
string g[maxn];
int dp[maxn][maxn];



bool viz[maxn][maxn];


const string S = "RGW";

int dfs() {
    int res = 0;
    auto row = [&](int i, int j) {
	for (int k=0; k<3; k++) {
	    if (viz[i][j+k]) return false;
	    if (g[i][j+k]!=S[k]) return false;
	}
	return true;
    };


    auto col = [&](int i, int j) {
	for (int k=0; k<3; k++) {
	    if (viz[i+k][j]) return false;
	    if (g[i+k][j]!=S[k]) return false;
	}
	return true;
    };

    
    for (int i=0; i<n; i++) {
	for (int j=0; j<m; j++) {
	    if (col(i,j)) {
		viz[i][j]=viz[i+1][j]=viz[i+2][j]=true;
		res = max(res, 1+dfs());
		viz[i][j]=viz[i+1][j]=viz[i+2][j]=false;
	    }
	    if (row(i,j)) {
		viz[i][j]=viz[i][j+1]=viz[i][j+2]=true;
		res = max(res, 1+dfs());
		viz[i][j]=viz[i][j+1]=viz[i][j+2]=false;
	    }
	}
    }
    return res;
}

int brute() {
    return dfs();
}


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    cin>>n>>m;
    for (int i=0; i<n; i++) {
	cin>>g[i];
    }

    cout<<brute()<<endl;
    
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...