#include <bits/stdc++.h>
#define ll long long
using namespace std;
int H,W;
deque<pair<int,int>*> R[3001],C[3001];
pair<int,int> V[3001][3001];
char c;
pair<int,int>* tmp;
int main() {
cin>>H>>W;
for(int i=0;i<H;i++)
for(int 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... |