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>
using namespace std;
using ll = long long;
int h, w;
vector<string> g;
vector<vector<ll>> a;
ll solve() {
ll ans = 0;
for (int i = 0; i < h; i++) {
ll c = 0;
for (int j = 0; j < w; j++) {
if (g[i][j] == 'J') c += a[h - 1][j] - a[i][j];
else if (g[i][j] == 'O') ans += c;
}
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> h >> w;
g.resize(h), a.resize(h, vector<ll>(w, 0));
for (int i = 0; i < h; i++) {
cin >> g[i];
for (int j = 0; j < w; j++) {
a[i][j] = (g[i][j] == 'I') + (i > 0 ? a[i - 1][j] : 0);
}
}
cout << solve() << '\n';
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... |