Submission #1258112

#TimeUsernameProblemLanguageResultExecution timeMemory
1258112kawhietBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
99 ms80968 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    vector<vector<int>> a(n + 1, vector<int>(m + 1));
    vector<vector<int>> b(n + 1, vector<int>(m + 1));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            a[i][j + 1] = a[i][j] + (s[i][j] == 'O');
            b[i + 1][j] = b[i][j] + (s[i][j] == 'I');
        }
    }
    int64_t ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i][j] == 'J') {
                ans += (a[i][m] - a[i][j]) * (b[n][j] - b[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...