Submission #1359805

#TimeUsernameProblemLanguageResultExecution timeMemory
1359805thesenBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
236 ms212208 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vll vector<ll>
#define vbool vector<bool>
#define pairll pair<ll, ll>
#define pb push_back
#define fi first
#define sc second

void solve(){
    ll n, m; cin >> n >> m;

    string s;
    vector<vll> jew(n+1, vll(m+1)), orb(n+1, vll(m+1)), ing(n+1, vll(m+1));
    for(ll i = 1; i <= n; i++){
        cin >> s;
        for(ll j = 1; j <= m; j++){
            orb[i][j] = orb[i][j-1];
            ing[i][j] = ing[i-1][j];
            if(s[j-1] == 'J'){
                jew[i][j] = 1;
            }else if(s[j-1] == 'O'){
                orb[i][j]++;
            }else{
                ing[i][j]++;
            }
        }
    }

    ll res = 0;
    for(ll i = 1; i <= n; i++){
        for(ll j = 1; j <= m; j++){
            if(!jew[i][j])continue;
            res += (orb[i][m] - orb[i][j]) * (ing[n][j] - ing[i][j]);
        }
    }cout << res << endl;
}

int main(){
    ll t = 1; //cin >> t;
    while(t--)solve();
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...