Submission #1310203

#TimeUsernameProblemLanguageResultExecution timeMemory
1310203husseinjuandaBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
286 ms151412 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int h, w; cin >> h >> w;
    vector<string> x(h);
    for(int i = 0; i < h; i++){
        cin >> x[i];
    }
    vector<vector<int>> orb(h, vector<int>(w));
    vector<vector<int>> ingot(h, vector<int>(w));
    for(int i = 0; i < h; i++){
        int co = 0;
        for(int y = w-1; y >= 0; y--){
            if(x[i][y] == 'O'){
                co++;
            }
            orb[i][y] = co;
        }
    }
    for(int y = 0; y < w; y++){
        int co = 0;
        for(int i = h-1; i >= 0; i--){
            if(x[i][y] == 'I'){
                co++;
            }
            ingot[i][y] = co;
        }
    }
    int sum = 0;
    for(int i = 0; i < h; i++){
        for(int y = 0; y < w; y++){
            if(x[i][y] == 'J'){
                sum += ingot[i][y] * orb[i][y];
            }
        }
    }
    cout << sum << "\n";
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...