Submission #1117995

#TimeUsernameProblemLanguageResultExecution timeMemory
1117995heeyBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
419 ms212828 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long


signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m; cin >> n >> m;
    vector<pair<int,int>> jw;
    vector<vector<int>> orb, ing;
    orb = ing = vector<vector<int>>(n, vector<int>(m));

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            char c; cin >> c;
            if(c == 'J') jw.emplace_back(i, j);
            else if(c == 'I') ing[i][j]++;
            else if(c == 'O') orb[i][j]++;
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = m - 2; j >= 0; j--){
            orb[i][j] += orb[i][j + 1];
        }
    }

    for(int i = 0; i < m; i++){
        for(int j = n - 2; j >= 0; j--){
            ing[j][i] += ing[j+1][i];
        }
    }



    int res = 0;
    for(pair<int,int> j : jw){
        res += orb[j.first][j.second] * ing[j.first][j.second];
    }
    cout << res << '\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...