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>
#define int long long
using namespace std;
signed main() {
int n, k; cin >> n >> k; vector<string> v(n);
for(int i=0;i<n;i++) cin >> v[i];
vector<vector<int>> a(n, vector<int>(k)), b(n, vector<int>(k));
for(int i=0;i<n;i++) for(int j=0;j<k;j++) {
if(v[i][j] == 'O') a[i][j]++;
if(j) a[i][j] += a[i][j-1];
}
for(int j=0;j<k;j++) for(int i=0;i<n;i++) {
if(v[i][j] == 'I') b[i][j]++;
if(i) b[i][j] += b[i-1][j];
}
int ans = 0;
for(int i=0;i<n;i++) for(int j=0;j<k;j++) if(v[i][j] == 'J') ans += (b[n-1][j]-b[i][j])*(a[i][k-1]-a[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... |