#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define all(v) v.begin(),v.end()
#define ar array
const int M = 1e6;
const int N = 4e5 + 20;
const int LOG = 61;
const int INF = 1e18;
const int MOD = 1e9 + 7;
const ld EPS = 1e-9;
inline void mm(int &x){x = (x % MOD + MOD) % MOD;}
inline void chmin(int &x, int y){x = min(x, y);}
inline void chmax(int &x, int y){x = max(x, y);}
#pragma GCC optimize("unroll-loops,O3")
void orz(){
int n, m;
cin>>n>>m;
string s[n];
for(int i = 0;i < n;i++)cin>>s[i];
int cnt[m] = {0};
int ans = 0;
for(int i = n - 1;i >= 0;i--){
int cc = 0;
for(int j = m - 1;j >= 0;j--){
if(s[i][j] == 'J')ans += cnt[j] * cc;
else if(s[i][j] == 'O')cc++;
}
for(int j = 0;j < m;j++)cnt[j] += s[i][j] == 'I';
}
cout<<ans;
}
signed main(){ios_base::sync_with_stdio(false);cin.tie(0);
int t = 1;
//cin>>t;
while(t--)orz();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |