Submission #495725

#TimeUsernameProblemLanguageResultExecution timeMemory
495725Jarif_RahmanBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
83 ms18900 KiB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m; cin >> n >> m;
    vector<str> v(n);
    for(str &s: v) cin >> s;

    vector<ll> ingots(m, 0LL);
    ll ans = 0;

    for(int i = n-1; i >= 0; i--){
        ll orbs = 0;
        for(int j = m-1; j >= 0; j--){
            if(v[i][j] == 'J') ans+=orbs*ingots[j];
            if(v[i][j] == 'O') orbs++;
            if(v[i][j] == 'I') ingots[j]++;
        }
    }

    cout << ans << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...