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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct item {
int o, i;
};
int32_t main() {
ios::sync_with_stdio(0); cin.tie(0);
int n, m; cin >> n >> m;
vector<vector<char>> a(n + 1, vector<char>(m + 1));
vector<vector<item>> cnt(n + 1, vector<item>(m + 1));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
if (a[i][j] == 'O') cnt[i][j].o++;
if (a[i][j] == 'I') cnt[i][j].i++;
cnt[i][j].o += cnt[i][j - 1].o;
cnt[i][j].i += cnt[i - 1][j].i;
}
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] == 'J') {
ans += (cnt[i][m].o - cnt[i][j].o) * (cnt[n][j].i - cnt[i][j].i);
}
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |