Submission #481159

#TimeUsernameProblemLanguageResultExecution timeMemory
481159LoboBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
88 ms18924 KiB
#include <bits/stdc++.h>
 
using namespace std;

const long long INFll = (long long) 1e18 + 10;
const int INFii = (int) 1e9 + 10;
typedef long long ll;
typedef int ii;
typedef long double dbl;
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

#define maxn 3300

ii n, m, sfi[maxn];
string s[maxn];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);

    //freopen("in.in", "r", stdin);
    //freopen("out.out", "w", stdout);

    cin >> n >> m;

    for(ii i = 1; i <= n; i++) {
        cin >> s[i];
    }

    ll ans = 0;

    for(ii i = n; i >= 1; i--) {
        ii orb = 0;
        for(ii j = m-1; j >= 0; j--) {
            if(s[i][j] == 'I') sfi[j]++;
            if(s[i][j] == 'O') orb++;
            if(s[i][j] == 'J') {
                ans+= sfi[j]*orb;
            }
        }
    }

    cout << ans << endl;

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...