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 <iostream>
#include <cstdio>
using namespace std;
const int N = 3005, M = 3005;
int m, n, f[M][N], g[M][N];
char s[M][N];
long long ans = 0;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> m >> n;
for (int i = 0; i < m; i++)
cin >> s[i];
for (int i = m - 1; i >= 0; i--)
for (int j = n - 1; j >= 0; j--)
{
f[i][j] = f[i + 1][j] + (s[i][j] == 'I');
g[i][j] = g[i][j + 1] + (s[i][j] == 'O');
if (s[i][j] == 'J')
ans += 1LL * f[i][j] * g[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... |