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;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,m;
vector<string>ciag;
string napis;
cin >> n >> m;
for(int i=0;i<n;++i){
cin >> napis;
ciag.push_back(napis);
}
int suma=0;
for(int i=0;i<n;++i){
for(int j=0;j<m;++j){
if(j+2<m && ciag[i][j]=='R' && ciag[i][j+1]=='G' && ciag[i][j+2]=='W'){
if(i+1 < n && i>0 && ciag[i-1][j+1]=='R' && ciag[i][j+1]=='G' && ciag[i+1][j+1]=='W'){
ciag[i-1][j+1]='X';
ciag[i][j+1]='X';
ciag[i][j+2]='X';
}
else{
ciag[i][j]='X';
ciag[i][j+1]='X';
ciag[i][j+2]='X';
}
suma++;
}
if(i>0 && i+1<n && ciag[i][j]=='G' && ciag[i-1][j]=='R' && ciag[i+1][j]=='W'){
//cout << i << " : " << j << "\n";
ciag[i][j]='X';
ciag[i-1][j]='X';
ciag[i+1][j]='X';
suma++;
}
}
}
/*for(int i=0;i<n;++i){
for(int j=0;j<m;++j){
cout << ciag[i][j];
}
cout << endl;
}
*/
cout << suma;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |