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 all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define x first
#define y second
using namespace std;
using ll = long long;
#define int ll
const int N = 3003;
int n, m;
char s[N][N];
int a[N][N];
int b[N][N];
int ans = 0;
signed main() {
#ifdef LC
assert(freopen("input.txt", "r", stdin));
#endif
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> m;
for (int i = 0; i < n; ++i) {
cin >> s[i];
}
for (int i = n - 1; i >= 0; --i) {
for (int j = m - 1; j >= 0; --j) {
a[i][j] = a[i][j + 1] + (s[i][j] == 'O');
b[i][j] = b[i + 1][j] + (s[i][j] == 'I');
if (s[i][j] == 'J') {
ans += a[i][j + 1] * b[i + 1][j];
}
}
}
cout << ans << "\n";
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... |