This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define int long long
#define lowbit(x) x&-x
const int maxn = 3000 + 5;
map<char, int> mp = {{'R', 0}, {'G', 1}, {'W', 2}};
int a[maxn][maxn], taken[maxn][maxn];
int n, m;
signed main(void){
fastio;
cin>>n>>m;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
char c;
cin>>c;
a[i][j] = mp[c];
}
}
int ans = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(j < m - 2){
if(a[i][j] == 0 && a[i][j + 1] == 1 && a[i][j + 2] == 2){
if(taken[i][j + 1] + taken[i][j + 2] == 0){
ans += 1;
taken[i][j] = 1;
}
}
}
if(!taken[i][j] && i < n - 2){
if(a[i][j] == 0 && a[i + 1][j] == 1 && a[i + 2][j] == 2){
taken[i][j] = taken[i + 1][j] = taken[i + 2][j] = 1;
ans++;
}
}
}
}
cout<<ans<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |