제출 #1304001

#제출 시각아이디문제언어결과실행 시간메모리
1304001nathlol2Bitaro the Brave (JOI19_ho_t1)C++20
100 / 100
92 ms87672 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 3333;
string tb[N];
int n, m, pf[2][N][N];
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;
    for(int i = 1;i<=n;i++){
        cin >> tb[i];
        tb[i] = " " + tb[i];
        for(int j = 1;j<=m;j++){
            pf[0][i][j] = pf[0][i][j - 1] + (tb[i][j] == 'O');
            pf[1][i][j] = pf[1][i - 1][j] + (tb[i][j] == 'I');
        }
    }
    long long ans = 0;
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            if(tb[i][j] == 'J'){
                ans += (pf[0][i][m] - pf[0][i][j]) * (pf[1][n][j] - pf[1][i][j]);
            }
        }
    }
    cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...