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;
#define ll long long
int main() {
int h, w; cin >> h >> w;
vector<string> grid(h);
for (int i=0;i<h;i++) {
cin >> grid[i];
}
vector<vector<int>> numsbelow, numsright;
vector<int> bruh(w);
for (int i=0;i<h;i++) {
numsbelow.push_back(bruh);
numsright.push_back(bruh);
}
int counter;
for (int i=0;i<w;i++) {
counter = 0;
for (int j=h-1;j>-1;j--) {
if (grid[j][i] == 'I') {
counter++;
} else if (grid[j][i] == 'J') {
numsbelow[j][i] = counter;
}
}
}
for (int i=0;i<h;i++) {
counter = 0;
for (int j=w-1;j>-1;j--) {
if (grid[i][j] == 'O') {
counter++;
} else if (grid[i][j] == 'J') {
numsright[i][j] = counter;
}
}
}
ll ans = 0;
for (int i=0;i<h;i++) {
for (int j=0;j<w;j++) {
if (grid[i][j] == 'J') {
ans += numsbelow[i][j] * numsright[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... |