#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int h, w;
cin >> h >> w;
vector<string> a(h);
for (int i = 0; i < h; i++) {
cin >> a[i];
}
long long ans = 0;
for (int i = 0; i < h; i++) {
for (int k = i + 1; k < h; k++) {
vector<int> demO(w + 1, 0);
for (int j = w - 1; j >= 0; j--) {
demO[j] = demO[j + 1] + (a[i][j] == 'O');
}
for (int j = 0; j < w; j++) {
if (a[i][j] == 'J' && a[k][j] == 'I') {
ans += demO[j + 1];
}
}
}
}
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... |