Submission #597228

#TimeUsernameProblemLanguageResultExecution timeMemory
597228AsymmetryDango Maker (JOI18_dango_maker)C++17
13 / 100
1 ms328 KiB
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define FOR(i,l,r) for(int i=(l);i<=(r);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) int(x.size())
template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';}
template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';}
#ifdef DEBUG
#define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...)<<'\n';}(x)
#else
#define debug(...) {}
#endif

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector<vector<char>> t(n, vector(m, 'a'));
	vector<vector<int>> v(n, vector(m, 0));
	REP (i, n) {
		REP (j, m) {
			cin >> t[i][j];
		}
	}

	int odp = 0;
	REP (x, n) {
		REP (y, m) {
			if ((y < m - 2) && (t[x][y] == 'R') && (t[x][y + 1] == 'G') && (t[x][y + 2] == 'W') && (v[x][y + 2] == 0)) {
				odp += 1 - v[x][y + 1];
				v[x][y] = v[x][y + 1] = v[x][y + 2] = 1;
				if (x < n - 1) {
					v[x + 1][y + 1] = 0;
				}
			}
			else if ((x < n - 2) && (t[x][y] == 'R') && (t[x + 1][y] == 'G') && (t[x + 2][y] == 'W')) {
				++odp;
				v[x][y] = v[x + 1][y] = v[x + 2][y] = 1;
			}
		}
	}
	cout << odp << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...