제출 #1349133

#제출 시각아이디문제언어결과실행 시간메모리
1349133killerzaluuBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
161 ms80952 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    for (int i = 0; i < h; i++) cin >> s[i];

    vector<vector<int>> r(h, vector<int>(w, 0));
    vector<vector<int>> d(h, vector<int>(w, 0));

    for (int i = 0; i < h; i++) {
        int cnt = 0;
        for (int j = w - 1; j >= 0; j--) {
            r[i][j] = cnt;
            if (s[i][j] == 'O') cnt++;
        }
    }

    for (int j = 0; j < w; j++) {
        int cnt = 0;
        for (int i = h - 1; i >= 0; i--) {
            d[i][j] = cnt;
            if (s[i][j] == 'I') cnt++;
        }
    }

    long long ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == 'J') {
                ans += 1LL * r[i][j] * d[i][j];
            }
        }
    }

    cout << ans << '\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...