Submission #1156899

#TimeUsernameProblemLanguageResultExecution timeMemory
1156899dnnndaBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
221 ms80152 KiB
#include<bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define ll long long
//#define int long long
//#pragma GCC optimize("Ofast, unroll-loop")
//#pragma GCC target("avx,avx2")
#pragma GCC optimize("O3")
const int inf=0x3f3f3f3f;
const ll inff=0x3f3f3f3f3f3f3f3f;
//const int X=1000000007;
const int X=998244353;

char c[3005][3005];
int ci[3005][3005], co[3005][3005];

signed main(){
    ios::sync_with_stdio(0), cin.tie(0);
    memset(ci,0,sizeof ci), memset(co,0,sizeof co);
    int h, w; cin >> h >> w;
    ll ans=0;
    for(int i=1 ; i<=h ; i++) for(int j=1 ; j<=w ; j++){
        cin >> c[i][j];
        if(c[i][j]=='O') co[i][j]++;
        if(c[i][j]=='I') ci[i][j]++;
    }
    for(int i=1 ; i<=h ; i++) for(int j=1 ; j<=w ; j++){
        co[i][j]+=co[i][j-1];
        ci[i][j]+=ci[i-1][j];
    }
    for(int i=1 ; i<=h ; i++) for(int j=1 ; j<=w ; j++){
        if(c[i][j]=='J') ans+=(co[i][w]-co[i][j])*(ci[h][j]-ci[i][j]);
    }
    cout << ans << '\n';


    return 0;
}

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