#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll = long long;
#define FOR(I, L, R) for(int I(L) ; I <= (int)R ; ++I)
#define FOD(I, R, L) for(int I(R) ; I >= (int)L ; --I)
#define FOA(I, A) for(auto &I : A)
#define print(A,L,R) FOR(OK, L, R){if(A[OK]<=-oo / 10||A[OK]>=oo)cout<<"- ";else cout<<A[OK]<<' ';}cout<<'\n';
#define prints(A) FOA(OK, A){cout<<OK<<' ';}cout << '\n';
#define printz(A,L,R) FOR(OK, 0, L){FOR(KO, 0, R){if(A[OK][KO]>-oo&&A[OK][KO]<oo)cout<<A[OK][KO]<<' ';else cout << "- ";} cout << '\n';}cout << '\n';
#define fs first
#define sd second
#define ii pair<int,int>
#define iii pair<int, ii>
#define all(A) A.begin(), A.end()
#define quickly ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N = 3000 + 5;
const int mod = 1e9 + 7;
const int oo = 1e18;
int n, m;
string a[N];
int orb[N][N], ing[N][N];
signed main(){ quickly
cin >> n >> m;
FOR(i, 1, n){
cin >> a[i];
a[i] = " " + a[i];
}
FOR(i, 1, n){
FOD(j, m, 1){
orb[i][j] = orb[i][j + 1] + (a[i][j] == 'O');
}
}
FOR(j, 1, m){
FOD(i, n, 1){
ing[i][j] = ing[i + 1][j] + (a[i][j] == 'I');
}
}
int ans = 0;
FOR(i, 1, n){
FOR(j, 1, m){
if(a[i][j] == 'J'){
ans += orb[i][j + 1] * ing[i + 1][j];
}
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |