Submission #1355092

#TimeUsernameProblemLanguageResultExecution timeMemory
1355092takoshanavaBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
129 ms11848 KiB
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fs first
#define sc second
using namespace std;

const int N = 3005;

int h, w;
string s[N];
int dn[N];

signed main() {
    cin >> h >> w;
    for (int i = 0; i < h; i++) cin >> s[i];

    int ans = 0;

    for (int i = h - 1; i >= 0; i--) {
        int pref = 0;
        for (int j = 0; j < w; j++) {
            if (s[i][j] == 'J') pref += dn[j];
            else if (s[i][j] == 'O') ans += pref;
        }
        for (int j = 0; j < w; j++) {
            if (s[i][j] == 'I') dn[j]++;
        }
    }

    cout << ans << endl;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...