Submission #1279653

#TimeUsernameProblemLanguageResultExecution timeMemory
1279653MinhKienBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
249 ms80944 KiB
#include <iostream>
#include <string>

using namespace std;

const int N = 3010;

int n, m;
int O[N][N], I[N][N];
string s[N];

int main() {
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        for (int j = m - 1; j >= 0; --j) {
            O[i][j] = O[i][j + 1];
            if (s[i][j] == 'O') ++O[i][j];
        }
    }

    for (int j = 0; j < m; ++j) {
        for (int i = n - 1; i >= 0; --i) {
            I[i][j] = I[i + 1][j];
            if (s[i][j] == 'I') ++I[i][j];
        }
    }

    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (s[i][j] == 'J') {
                ans += 1ll * O[i][j] * I[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...