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;
using ll = long long;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
ll n,m;
cin >> n >> m;
vector<string> a(n);
for(auto &o : a) cin >> o;
vector<vector<ll>> vis(n,vector<ll>(m,0));
ll ans = 0;
for(ll x = n-1;x>=0;x--){
for(ll y = 0;y<m;y++){
ll i = x;
ll j = y;
if (vis[i][j]) continue;
ll cnt = 0;
while(i<n&&j<m){
cnt++;
vis[i][j] = 1;
if (a[i][j]=='R'){
if (j+2<m&&a[i][j+1]=='G'&&a[i][j+2]=='W'){
j+=2;
continue;
}
}else if (a[i][j]=='W'){
if (i>=2&&a[i-1][j]=='G'&&a[i-2][j]=='R'){
i-=2;
continue;
}
}
break;
}
ans += cnt/2;
}
}
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... |