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 num long long
const int W = 3000;
const int H = W;
num dp0[W][H];
num dp1[W][H];
bool dp2[W][H];
int main () {
int w, h;
cin >> w >> h;
for (int i = 0; i < w; i ++) {
string b;
cin >> b;
for (int j = 0; j < h; j ++) {
if (b[j] == 'J') dp2[i][j] = true;
if (b[j] == 'O') dp1[i][j] = 1;
if (b[j] == 'I') dp0[i][j] = 1;
}
}
for (int i = w - 2; i >= 0; i --)
for (int j = 0; j < h; j ++)
dp0[i][j] += dp0[i + 1][j];
for (int j = h - 2; j >= 0; j --)
for (int i = 0; i < w; i ++)
dp1[i][j] += dp1[i][j + 1];
num ans = 0;
for (int i = 0; i < w; i ++)
for (int j = 0; j < h; j ++)
if (dp2[i][j])
ans += dp0[i][j] * dp1[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... |