Submission #1273652

#TimeUsernameProblemLanguageResultExecution timeMemory
1273652kaiboyDango Maker (JOI18_dango_maker)C++20
100 / 100
92 ms9244 KiB
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 3000;
const int M = 3000;

char cc[N][M + 1];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> cc[i];
	int ans = 0;
	for (int i_ = 0, j_ = 0; i_ < n && j_ < m; (i_ + 1 < n ? i_ : j_)++) {
		int x = 0, y = 0, z = 0;
		for (int i = i_, j = j_; i >= 0 && j < m; i--, j++) {
			int x_ = max(x, max(y, z));
			int y_ = j && j + 1 < m && cc[i][j - 1] == 'R' && cc[i][j] == 'G' && cc[i][j + 1] == 'W' ? max(x, y) + 1 : 0;
			int z_ = i && i + 1 < n && cc[i - 1][j] == 'R' && cc[i][j] == 'G' && cc[i + 1][j] == 'W' ? max(x, z) + 1 : 0;
			x = x_, y = y_, z = z_;
		}
		ans += max(x, max(y, z));
	}
	cout << ans << '\n';
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...