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;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=3e3+2;
char a[N][N];
int psi[N][N];
int pso[N][N];
signed main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
pso[i][j]=pso[i][j-1];
if(a[i][j]=='O')pso[i][j]++;
}
}
for(int j=1;j<=m;j++){
for(int i=1;i<=n;i++){
psi[i][j]=psi[i-1][j];
if(a[i][j]=='I')psi[i][j]++;
}
}
int ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]=='J'){
ans+= (pso[i][m]-pso[i][j])*(psi[n][j]-psi[i][j]);
}
}
}
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... |