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;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int h, w;
cin >> h >> w;
vector<string> grid(h);
for (int i = 0; i < h; i++) {
cin >> grid[i];
}
vector<vector<int>> ibelow(h, vector<int>(w));
for (int c = 0; c < w; c++) {
int i = 0;
for (int r = h - 1; r >= 0; r--) {
i += (grid[r][c] == 'I');
ibelow[r][c] = i;
}
}
long long ans = 0;
for (int r = 0; r < h; r++) {
int o = 0;
for (int c = w - 1; c >= 0; c--) {
o += (grid[r][c] == 'O');
if (grid[r][c] == 'J') {
ans += ibelow[r][c] * o;
}
}
}
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... |