// g++ -Wall -Wextra -std=c++17 -o A A.cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
#define fs first
#define sc second
#define MP make_pair
int n, m;
string s[3010];
int colI[3010] = {0}, rowO[3010] = {0};
ll ans = 0;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> s[i];
for (int j = 0; j < m; j++) {
if (s[i][j] == 'O') rowO[i]++;
if (s[i][j] == 'I') colI[j]++;
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (s[i][j] == 'O') rowO[i]--;
if (s[i][j] == 'I') colI[j]--;
if (s[i][j] == 'J') ans += rowO[i] * colI[j];
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |