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 N = 3030;
char c[N][N];
int qs[2][N][N];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int i = 1;i <= n;i++) {
cin >> (c[i] + 1);
for (int j = 1;j <= m;j++) {
qs[0][i][j] = qs[0][i][j - 1] + (c[i][j] == 'O');
qs[1][i][j] = qs[1][i - 1][j] + (c[i][j] == 'I');
}
}
ll ans = 0;
for (int i = 1;i < n;i++) {
for (int j = 1;j < m;j++) {
if (c[i][j] == 'J') {
ans += 1ll * (qs[0][i][m] - qs[0][i][j]) * (qs[1][n][j] - qs[1][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... |