제출 #1258729

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

using ll = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, m;
    cin >> n >> m;
    vector<string> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] = " " + a[i];
    }
    vector<vector<ll>> xeto(n + 2, vector<ll>(m + 2, 0));
    vector<vector<ll>> xeti(n + 2, vector<ll>(m + 2, 0));
    for (int i = 1; i <= n; i++) {
        for (int j = m; j >= 1; j--) {
            xeto[i][j] = xeto[i][j + 1] + (a[i][j] == 'O');
        }
    }
    for (int j = 1; j <= m; j++) {
        for (int i = n; i >= 1; i--) {
            xeti[i][j] = xeti[i + 1][j] + (a[i][j] == 'I');
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            ans += xeto[i][j] * xeti[i][j] * (a[i][j] == 'J');
        }
    }
    cout << ans << "\n";
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...