Submission #878753

#TimeUsernameProblemLanguageResultExecution timeMemory
878753niterBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
365 ms79796 KiB
#include <bits/stdc++.h>
#define pb push_back
#define ins isnert
#define pii pair<int,int>
#define ff first
#define ss second
#define loop(i,a,b) for(int i = (a); i < (b); i ++)
#define op(x) cerr << #x << " = " << x << endl;
#define opa(x) cerr << #x << " = " << x << ", ";
#define ops(x) cerr << x;
#define spac cerr << ' ';
#define entr cerr << endl;
#define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl;
#define ARR(x, nnn) cerr << #x << " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl;
#define BAE(x) (x).begin(), (x).end()
using namespace std;

const int mxn = 3005;
char c[mxn][mxn];
int suf_o[mxn][mxn], suf_i[mxn][mxn];

int main(){
    int n, m;
    cin >> n >> m;
    loop(i,0,n){
        loop(j,0,m){
            cin >> c[i+1][j+1];
        }
    }
    loop(i,1,n+1){
        for(int j = m; j >= 1; j--){
            suf_o[i][j] += suf_o[i][j+1] + (c[i][j] == 'O');
        }
    }
    for(int i = n; i >= 1; i--){
        loop(j,1,m+1){
            suf_i[i][j] += suf_i[i+1][j] + (c[i][j] == 'I');
        }
    }
    long long ans = 0;
    loop(i,1,n+1){
        loop(j,1,m+1){
            if(c[i][j] == 'J'){
                ans += suf_o[i][j] * suf_i[i][j];
            }
        }
    }
    cout << ans << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...