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 int long long int
void solve() {
int n, m, ans = 0;
cin >> n >> m;
vector<int> ai(m, 0), aj(n, 0);
vector<string> grid(n);
for (auto &x : grid) {
cin >> x;
}
for (int i = n-1; i >= 0; i--) {
for (int j = m-1; j >= 0; j--) {
if (grid[i][j] == 'J') {
ans += aj[i]*ai[j];
} else if (grid[i][j] == 'O') {
aj[i]++;
} else if (grid[i][j] == 'I') {
ai[j]++;
}
}
}
cout << ans << endl;
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
t = 1;
while(t--) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |