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 <iostream>
#include <algorithm>
using namespace std;
int a[3000][3000]={-1};
long long ans = 0 ;
int main() {
int n,m;
cin>>n>>m;
for(int i = 2 ; i<n+2; i++){
for(int j = 2 ; j<m+2; j++){
char h;
cin>>h;
if(h=='R'){
a[i][j]=0;
}
else if(h=='G'){
a[i][j]=1;
}
else{
a[i][j]=2;
}
}
}
for(int i = 2 ; i<n+2; i++){
for(int j = 2 ;j<m+2; j++){
if(a[i][j]==0&&a[i][j+1]==1&&a[i][j+2]==2){
ans++;
a[i][j]=-1;
a[i][j+1]=-1;
a[i][j+2]=-1;
}
else if(a[i][j]==0&&a[i+1][j]==1&&a[i+2][j]==2){
if(a[i+1][j-1]==0&&a[i+1][j+1]==2&&a[i+2][j-2]==0&&a[i+2][j-1]==1){
a[i+1][j-1]=-1;
a[i+1][j+1]=-1;
a[i+2][j-2]=-1;
a[i+2][j-1]=-1;
ans+=2;
}
else{
a[i][j]=-1;
a[i+1][j]=-1;
a[i+2][j]=-1;
ans+=1;
}
}
}
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |