Submission #1014642

#TimeUsernameProblemLanguageResultExecution timeMemory
1014642snpmrnhlolBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
404 ms88408 KiB
#include<bits/stdc++.h>
using namespace std;
const int N = 3e3;
char v[N][N];
int cnt1[N][N];
int cnt2[N][N];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            cin>>v[i][j];
        }
    }
    long long ans = 0;
    for(int i = n - 1;i >= 0;i--){
        for(int j = m - 1;j >= 0;j--){
            cnt1[i][j] = (j == m - 1?0:cnt1[i][j + 1]) + (v[i][j] == 'O');
            cnt2[i][j] = (i == n - 1?0:cnt2[i + 1][j]) + (v[i][j] == 'I');
            if(v[i][j] == 'J')ans+=cnt1[i][j]*cnt2[i][j];
        }
    }
    cout<<ans;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...