Submission #1248575

#TimeUsernameProblemLanguageResultExecution timeMemory
1248575hamaseBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
471 ms150556 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define mp make_pair
#define fi first
#define se second

ll H, W, os[3010][3010], is[3010][3010];
char s[3010][3010];

int main() {
    cin >> H >> W;
    for (int i = 1; i <= H; i++) {
        os[i][0] = 0;
        for (int j = 1; j <= W; j++) {
            cin >> s[i][j];
            os[i][j] = os[i][j-1] + (s[i][j] == 'O');
        }
    }
    for (int j = 1; j <= W; j++) {
        is[0][j] = 0;
        for (int i = 1; i <= H; i++) {
            is[i][j] = is[i-1][j] + (s[i][j] == 'I');
        }
    }
    ll ans = 0;
    for (int i = 1; i < H; i++) {
        for (int j = 1; j < W; j++) {
            if (s[i][j] != 'J') continue;
            ans += (os[i][W] - os[i][j])*(is[H][j] - is[i][j]);
        }
    }
    cout << ans << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...