제출 #1258761

#제출 시각아이디문제언어결과실행 시간메모리
1258761khanhanBitaro the Brave (JOI19_ho_t1)C++20
50 / 100
1094 ms9544 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> a(h);
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }

    long long ans = 0;

     
    for (int i = 0; i < h; i++) {
        for (int k = i + 1; k < h; k++) {
             
            vector<int> demO(w + 1, 0);
            for (int j = w - 1; j >= 0; j--) {
                demO[j] = demO[j + 1] + (a[i][j] == 'O');
            }

            for (int j = 0; j < w; j++) {
                if (a[i][j] == 'J' && a[k][j] == 'I') {
                    ans += demO[j + 1];
                }
            }
        }
    }

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