#include <bits/stdc++.h>
using namespace std;
int numRow, numCol;
char a[3030][3030];
int sumI[3030];
int main() {
ios_base::sync_with_stdio(false);cin.tie(nullptr);
cin >> numRow >> numCol;
for (int i = 1; i <= numRow; ++i) {
string s; cin >> s;
for (int j = 1; j <= numCol; ++j) {
a[i][j] = s[j - 1];
}
}
long long ans = 0;
for (int i = numRow; i >= 1; --i) {
long long pre = 0;
for (int j = 1; j <= numCol; ++j) {
if (a[i][j] == 'I') sumI[j] += 1;
else if (a[i][j] == 'J') pre += sumI[j];
else ans += pre;
}
}
cout << ans;
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... |