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;
void testCase() {
int n, m;
cin >> n >> m;
vector<string> a(n);
for (auto &s : a) {
cin >> s;
}
vector<vector<int>> ingot(n + 1, vector<int>(m + 1)), orb(n + 1, vector<int>(m + 1));
int64_t ans = 0;
for (int i = n - 1; i >= 0; --i) {
for (int j = m - 1; j >= 0; --j) {
if (a[i][j] == 'J') {
ans += (int64_t)ingot[i + 1][j] * orb[i][j + 1];
}
ingot[i][j] = ingot[i + 1][j] + (a[i][j] == 'I');
orb[i][j] = orb[i][j + 1] + (a[i][j] == 'O');
}
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int tests = 1;
for (int tc = 0; tc < tests; ++tc) {
testCase();
}
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... |