#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll H,W;
vector<pair<ll,ll>*> R[3001],C[3001];
pair<ll,ll> V[3001][3001];
char c;
pair<ll,ll>* tmp;
int main() {
cin>>H>>W;
for(ll i=0;i<H;i++)
for(ll j=0;j<W;j++){
cin>>c;
if(c=='J'){
R[i].push_back(&V[i][j]);
C[j].push_back(&V[i][j]);
//cout<<R[i].back()->first<<" "<<R[i].back()->second<<"\n";
}
if(c=='O'){
for(auto &it:R[i])
it->first+=1;
}
if(c=='I'){
for(auto &it:C[j])
it->second+=1;
}
}
ll cnt=0;
for(ll i=0;i<H;i++)
for(auto it:R[i])
cnt+=it->first * it->second;
cout<<cnt;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |