Submission #334244

#TimeUsernameProblemLanguageResultExecution timeMemory
334244Tahmid690Bitaro the Brave (JOI19_ho_t1)C++14
0 / 100
1 ms364 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int h,w;
    string s[3005];
    cin >> h >> w;
    for(int i=0;i<h;i++) cin >> s[i];
    unordered_map<int,ll> rows;
    unordered_map<int,ll> colum;
    for(int i=0;i<h;i++){
        ll x=0,y=0;
        for(int j=0;j<w;j++){
            if(s[i][j]=='O') x++;
            if(s[j][i]=='I') y++;
        }
        rows[i]=x;
        colum[i]=y;
       // cout << "Row " << i << " " << x << endl;
       // cout << "Col " << i << " " << y << endl;
    }
    ll ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='J') ans+=(rows[i]*colum[j]);
        }
    }
    cout << ans << endl;
    
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...