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 <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef int64_t llo;
#define a first
#define b second
#define endl "\n"
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
int it[n][m];
char s;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>s;
if(s=='R'){
it[i][j]=0;
}
else if(s=='G'){
it[i][j]=1;
}
else{
it[i][j]=2;
}
}
}
int tot=0;
for(int ii=0;ii<n+m-1;ii++){
int co=0;
int co2=0;
for(int jj=0;jj<ii+1;jj++){
int i,j;
j=jj;
i=ii-j;
if(i>=n or j>=m){
continue;
}
/*if(ii<=min(n,m)-1){
j=jj;
i=ii-j;
}
else{
j=ii-(min(n,m)-1);
i=ii-j;
}*/
if(j>0 and it[i][j-1]==0 and j+1<m and it[i][j+1]==2 and it[i][j]==1){
if(j%2==0){
co+=1;
}
else{
co2+=1;
}
}
else{
if(j%2==0){
tot+=(co+1)/2;
co=0;
}
else{
tot+=(co2+1)/2;
co2=0;
}
}
if(i>0 and i+1<n and it[i-1][j]==0 and it[i+1][j]==2 and it[i][j]==1){
if(j%2==1){
co+=1;
}
else{
co2+=1;
}
}
else{
if(j%2==1){
tot+=(co+1)/2;
co=0;
}
else{
tot+=(co2+1)/2;
co2=0;
}
}
}
tot+=(co+1)/2;
tot+=(co2+1)/2;
//cout<<tot<<endl;
}
cout<<tot<<endl;
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... |