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 N = 3000;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int n, m; cin >> n >> m;
static string s[N];
for (int i = 0; i < n; i++) cin >> s[i];
static int co[N][N], ci[N][N];
long long ans = 0;
for (int i = n - 1; i >= 0; i--) for (int j = m - 1; j >= 0; j--) {
if (j < m - 1) co[i][j] += co[i][j + 1];
if (i < n - 1) ci[i][j] += ci[i + 1][j];
if (s[i][j] == 'J') ans += co[i][j] * ci[i][j];
else if (s[i][j] == 'O') co[i][j]++;
else ci[i][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... |