제출 #573111

#제출 시각아이디문제언어결과실행 시간메모리
573111colossal_pepeBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
101 ms89344 KiB
#include <iostream>
#include <vector>
using namespace std;

using ll = long long;

int h, w;
vector<string> g;
vector<vector<ll>> a;

ll solve() {
    ll ans = 0;
    for (int i = 0; i < h; i++) {
        ll c = 0;
        for (int j = 0; j < w; j++) {
            if (g[i][j] == 'J') c += a[h - 1][j] - a[i][j];
            else if (g[i][j] == 'O') ans += c;
        }
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> h >> w;
    g.resize(h), a.resize(h, vector<ll>(w, 0));
    for (int i = 0; i < h; i++) {
        cin >> g[i];
        for (int j = 0; j < w; j++) {
            a[i][j] = (g[i][j] == 'I') + (i > 0 ? a[i - 1][j] : 0);
        }
    }
    cout << solve() << '\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...