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;
#define int long long
const int MAXN = 3010;
int pfCol[MAXN][MAXN];
int pfRow[MAXN][MAXN];
char mat[MAXN][MAXN];
int32_t main() {
//freopen("in", "r", stdin);
int h, w;
cin >> h >> w;
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
cin >> mat[i][j];
}
}
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
pfRow[i][j] = pfRow[i][j - 1];
if (mat[i][j] == 'O') pfRow[i][j]++;
}
}
for (int i = 1; i <= w; i++) {
for (int j = 1; j <= h; j++) {
pfCol[i][j] = pfCol[i][j - 1];
if (mat[j][i] == 'I') pfCol[i][j]++; // coluna i, row j
}
}
int ans = 0;
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
if (mat[i][j] == 'J') ans += ((pfRow[i][w] - pfRow[i][j - 1])*(pfCol[j][h] - pfCol[j][i - 1]));
}
}
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... |