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>
#define DEBUG 0
using namespace std;
const int N = 3e3 + 10;
char S[N][N];
int qsi[N][N], qso[N][N];
int main() {
cin.tie(0)->sync_with_stdio(0);
int H, W;
cin >> H >> W;
for(int i = 1; i <= H; i++) {
cin >> (S[i] + 1);
}
for(int i = 1; i <= H; i++) {
for(int j = 1; j <= W; j++) {
qso[i][j] = qso[i][j - 1] + (S[i][j] == 'O');
qsi[i][j] = qsi[i - 1][j] + (S[i][j] == 'I');
}
}
long long ans = 0;
for(int i = 1; i <= H; i++) {
for(int j = 1; j <= W; j++) {
ans += 1ll*(S[i][j] == 'J') * (qso[i][W] - qso[i][j]) * (qsi[H][j] - qsi[i][j]);
}
}
cout << ans;
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... |