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 fast ios::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
#define f first
#define s second
#define LOGN 21
const ll MOD = 1e9 + 7;
const ll MAXN = 3000 + 100;
#define int long long
vector<string> grid;
int toR[MAXN][MAXN], toD[MAXN][MAXN];
signed main() {
fast;
int H, W;
cin >> H >> W;
grid = vector<string>(H+1);
for (int i = 1; i <= H; i++) {
cin >> grid[i];
grid[i] = "#" + grid[i];
}
for (int i = 1; i <= H; i++) {
for (int j = W; j >= 1; j--)
toR[i][j] = toR[i][j+1] + (grid[i][j] == 'O');
}
for (int i = 1; i <= W; i++) {
for (int j = H; j >= 1; j--)
toD[j][i] = toD[j+1][i] + (grid[j][i] == 'I');
}
int ans = 0;
for (int i = 1; i <= H; i++) {
for (int j = 1; j <= W; j++) {
if (grid[i][j] == 'J')
ans += toR[i][j] * toD[i][j];
}
}
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... |