#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define _ << " " <<
#define yes cout << "Yes\n"
#define no cout << "No\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fasterAndfaster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9+7;
const ll INF = 1e9;
void solve() {
ll i, j, cnt = 0, sum = 0, ans = 0;
string ug, ug1, ug2;
char useg = 'a';
ll h, w;
cin >> h >> w;
vector<string> g(h);
for(auto &x: g) cin >> x;
for(i = 0; i < h; i++){
for(j = 0; j < w; j++){
if(g[i][j] == 'J'){
ll cnt1 = 0, cnt2 = 0;
for(ll i1 = i + 1; i1 < h; i1++){
if(g[i1][j] == 'I') cnt1++;
}
for(ll j1 = j + 1; j1 < w; j1++){
if(g[i][j1] == 'O') cnt2++;
}
cnt += cnt1 * cnt2;
}
}
}
cout << cnt << '\n';
}
int main(){
fasterAndfaster;
ll t = 1;
//cin >> t;
while(t--){
solve();
}
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... |