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;
const int DIM = 3005;
char mat[DIM][DIM];
int psm1[DIM][DIM], psm2[DIM][DIM];
int main(void) {
#ifdef HOME
freopen("brave.in", "r", stdin);
freopen("brave.out", "w", stdout);
#endif
int n, m; cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> (mat[i] + 1); }
long long ans = 0;
for (int i = n; i >= 1; --i) {
for (int j = m; j >= 1; --j) {
psm1[i][j] = psm1[i][j + 1] + (mat[i][j] == 'O');
psm2[i][j] = psm2[i + 1][j] + (mat[i][j] == 'I');
if (mat[i][j] == 'J') {
ans += psm1[i][j] * psm2[i][j]; } } }
cout << ans << 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... |