Submission #1350897

#TimeUsernameProblemLanguageResultExecution timeMemory
1350897AMel0nBitaro the Brave (JOI19_ho_t1)C++20
20 / 100
6 ms3396 KiB
#include <bits/stdc++.h>
using namespace std;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<vector<int>> G(H, vector<int>(W)), orb(H, vector<int>(W)), ingot(H, vector<int>(W));
    for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) {
        char c; cin >> c;
        if (c == 'O') G[i][j] = 1;
        if (c == 'I') G[i][j] = -1;
    }
    for(int i = 0; i < H; i++) {
        int cnt = 0;
        for(int j = W-1; j >= 0; j--) {
            orb[i][j] = cnt;
            cnt += G[i][j] == 1;
        }
    }
    for(int j = 0; j < W; j++) {
        int cnt = 0;
        for(int i = H-1; i >= 0; i--) {
            ingot[i][j] = cnt;
            cnt += G[i][j] == -1;
        }
    }
    int re = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if (!G[i][j]) re += orb[i][j] * ingot[i][j];
        }
    }
    cout << re ;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...