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 h, w;
char grid[3010][3010];
int x[3010][3010];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> h >> w;
for (int j = 0; j < h; j++)
for (int i = 0; i < w; i++)
cin >> grid[i][j];
for (int j = 0; j < h; j++) {
int k = 0;
for (int i = w; i >= 0; i--) {
// cout << i << ',' << j << ' ' << grid[i][j] << '\n';
if (grid[i][j] == 'O') k++;
if (grid[i][j] == 'J') {
// cout << "-> " << i << ',' << j << ' ' << k << '\n';
x[i][j] = k;
}
}
// cout << "\n";
}
long long ans = 0;
for (int i = 0; i < w; i++) {
int k = 0;
for (int j = 0; j < h; j++) {
k += x[i][j];
// cout << i << ',' << j << ' ' << grid[i][j] << ' ' << k << '\n';
if (grid[i][j] == 'I') {
ans += k;
// cout << "-> " << i << ',' << j << ' ' << k << '\n';
}
}
// cout << '\n';
}
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... |