Submission #99244

#TimeUsernameProblemLanguageResultExecution timeMemory
99244imeimi2000Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
181 ms85456 KiB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long llong;

int h, w;
char grid[3000][3001];
int Ocnt[3001][3001];
int Icnt[3001][3001];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        cin >> grid[i];
    }
    for (int i = h; i--; ) {
        for (int j = w; j--; ) {
            Ocnt[i][j] = Ocnt[i][j + 1];
            Icnt[i][j] = Icnt[i + 1][j];
            if (grid[i][j] == 'O') ++Ocnt[i][j];
            if (grid[i][j] == 'I') ++Icnt[i][j];
        }
    }
    llong ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (grid[i][j] == 'J') ans += Ocnt[i][j] * Icnt[i][j];
        }
    }
    printf("%lld\n", ans);
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...