제출 #1176851

#제출 시각아이디문제언어결과실행 시간메모리
1176851TsaganaDango Maker (JOI18_dango_maker)C++20
100 / 100
141 ms18060 KiB
#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second

using namespace std;

char a[3001][3001];
bool u[3001][3001];
int ans = 0;

void solve () {
	int n, m;
	cin >> n >> m;
	
	for (int i = 0; i < n; i++)
	for (int j = 0; j < m; j++)
		cin >> a[i][j];
	
	for (int i = 0; i < n; i++)
	for (int j = 0; j < m; j++) {
		if (a[i][j] != 'R') continue ;
		if (j < m - 2 && a[i][j+1] == 'G' && a[i][j+2] == 'W' && !(u[i][j+1] + u[i][j+2])) ans++;
		else if (i < n-2 && a[i+1][j] == 'G' && a[i+2][j] == 'W') {
			if (j>0 && j < m-1 && a[i+1][j-1]=='R' && a[i+1][j+1]=='W' && !u[i+1][j+1]) u[i+1][j] = 1;
			else u[i+2][j] = 1;
			ans++;
		}
	}
	cout << ans;
}
signed main() {IOS solve(); return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...