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;
using ll = long long;
const int MAXH = 3010;
const int MAXW = 3010;
int H, W;
char G[MAXH][MAXW];
int sumO[MAXH][MAXW];
int sumI[MAXH][MAXW];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> H >> W;
for (int i = 0; i < H; i++) {
cin >> G[i];
}
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
sumO[i][j+1] = sumO[i][j] + (G[i][j] == 'O');
}
}
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
sumI[i+1][j] = sumI[i][j] + (G[i][j] == 'I');
}
}
ll ans = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (G[i][j] == 'J') {
ans += (sumO[i][W] - sumO[i][j]) * (sumI[H][j] - sumI[i][j]);
}
}
}
cout << ans << '\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... |