제출 #1260006

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int h, w; 
    if (!(cin >> h >> w)) return 0;
    vector<string> a(h);
    for (int i = 0; i < h; ++i) cin >> a[i];

    vector<vector<int>> r(h, vector<int>(w, 0)), d(h, vector<int>(w, 0));
    for (int i = 0; i < h; ++i) {
        int c = 0;
        for (int j = w - 1; j >= 0; --j) {
            r[i][j] = c;
            if (a[i][j] == 'O') ++c;
        }
    }
    for (int j = 0; j < w; ++j) {
        int c = 0;
        for (int i = h - 1; i >= 0; --i) {
            d[i][j] = c;
            if (a[i][j] == 'I') ++c;
        }
    }

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

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