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;
using ll = long long;
const int maxn=3e3+5;
int n,m;
char c[maxn][maxn];
int dp[2][maxn][maxn];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
cin >> c[i][j];
dp[0][i][j] = dp[0][i - 1][j] + (c[i][j] == 'I');
dp[1][i][j] = dp[1][i][j - 1] + (c[i][j] == 'O');
}
}
ll ans = 0;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
if(c[i][j] != 'J') continue;
// cout<<i<<' '<<j<<' '<<dp[0][n][j]<<' '<<dp[0][i][j]<<' '<<dp[1][i][m]<<' '<<dp[1][i][j]<<'\n';
ans += (dp[0][n][j] - dp[0][i][j]) * (dp[1][i][m] - dp[1][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... |