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
#define pii pair<long long, long long>
#define t3i tuple<long long, long long, long long>
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<vector<char>> a(n, vector<char>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> a[i][j];
}
}
vector<vector<int>> os(n, vector<int>(m + 1)), is(n + 1, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = m - 1; j >= 0; j--) {
os[i][j] = os[i][j + 1] + (a[i][j] == 'O');
}
}
for (int j = 0; j < m; j++) {
for (int i = n - 1; i >= 0; i--) {
is[i][j] = is[i + 1][j] + (a[i][j] == 'I');
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (a[i][j] == 'J') {
ans += os[i][j] * is[i][j];
}
}
}
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... |