Submission #646905

#TimeUsernameProblemLanguageResultExecution timeMemory
646905OlsonBitaro the Brave (JOI19_ho_t1)C++17
20 / 100
9 ms4664 KiB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    int h,w;cin>>h>>w;
    ll pso[h+1][w+1];
    ll psi[h+1][w+1];
    for(int i=0; i<=h; i++)psi[i][0]=0;
    for(int i=0; i<=w; i++)pso[0][i]=0;
    string s[h];
    for(int i=0; i<h; i++)cin>>s[i];
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            psi[i][j]=psi[i-1][j];
            pso[i][j]=pso[i][j-1];
            if(s[i-1][j-1]=='I')psi[i][j]++;
            if(s[i-1][j-1]=='O')pso[i][j]++;
        }
    }
    int ans=0;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(s[i-1][j-1]=='J'){
                int m = psi[h][j]-psi[i][j];
                int n = pso[i][w]-pso[i][j];
                ans+=m*n;
            }
        }
    }
    cout<<ans<<endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...