#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define int long long
#define fr first
#define sc second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
int mod = 1e9 + 7;
const int N = 2 * 1e5;
void solve() {
int n,m;
cin >> n >> m;
char a[n][m];
vector<int> I,J,L,K;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> a[i][j];
if (a[i][j] == 'J') {
I.pb(i+1);
J.pb(j+1);
}
else if (a[i][j] == 'O') {
I.pb(i+1);
L.pb(j+1);
}
else {
K.pb(i+1);
J.pb(j+1);
}
}
}
int ans = 0;
for (int i = 0; i < (int)I.size(); i++) {
for (int j = 0; j < (int)J.size(); j++) {
for (int k = 0; k < (int)K.size(); k++) {
for (int l = 0; l < (int)L.size(); l++) {
if (1 <= I[i] && I[i] < K[k] && K[k] <= n && 1 <= J[j] && J[j] < L[l] && L[l] <= m) {
ans++;
I[i] = 4000;
K[k] = 4000;
J[j] = 4000;
L[l] = 4000;
}
}
}
}
}
cout << ans;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// Isa2011
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |