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;
typedef long long ll;
typedef long double ld;
int main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
int h, w;
cin >> h >> w;
vector<string> s(h);
for (int i = 0; i < h; ++i) {
cin >> s[i];
}
vector<vector<int>> r(h, vector<int>(w, 0));
for (int i = 0; i < h; ++i) {
int cnt = 0;
for (int j = w - 1; j >= 0; --j) {
if (s[i][j] == 'O') ++cnt;
r[i][j] = cnt;
}
}
vector<vector<int>> d(h, vector<int>(w, 0));
for (int j = 0; j < w; ++j) {
int cnt = 0;
for (int i = h - 1; i >= 0; --i) {
if (s[i][j] == 'I') ++cnt;
d[i][j] = cnt;
}
}
ll ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (s[i][j] == 'J') ans += r[i][j] * d[i][j];
}
}
cout << ans << endl;
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... |