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;
typedef long long ll;
typedef pair<ll,ll> pi;
char arr[3005][3005];
short dp[3005][3005];
short DP[3005][3005];
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n,m; cin>>n>>m;
for(int i=1; i<=n; i++) cin>>(arr[i]+1);
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
if(arr[i][j]=='O') dp[i][j] = 1;
if(arr[i][j]=='I') DP[i][j] = 1;
}
for(int j=m; j>=1; j--) dp[i][j]+=dp[i][j+1];
}
for(int i=1; i<=m; i++){
for(int j=n; j>=1; j--) DP[j][i]+=DP[j+1][i];
}
ll ans = 0;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
if(arr[i][j]!='J') continue;
ll w = dp[i][j];
w*=DP[i][j];
ans+=w;
}
}
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... |