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;
int main () {
int n, m; cin >> n >> m;
vector<string> grid(n);
for (int i = 0; i < n; i++) {
cin >> grid[i];
}
vector<int> occsCols(m, 0);
vector<int> occsLins(n, 0);
for (int y = 0; y < n; y++) {
for (int x = 0; x < m; x++) {
if (grid[y][x] == 'O') occsLins[y]++;
}
}
for (int x = 0; x < m; x++) {
for (int y = 0; y < n; y++) {
if (grid[y][x] == 'I') occsCols[x]++;
}
}
long long ans = 0;
for (int y = 0; y < n; y++) {
for (int x = 0; x < m; x++) {
if (grid[y][x] == 'J') {
ans += occsCols[x] * occsLins[y];
}
}
}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... |