#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
//#pragma GCC target("popcnt")
using namespace __gnu_pbds;
using namespace std;
using ordered_set = tree<int, null_type, less_equal<>, rb_tree_tag, tree_order_statistics_node_update>;
#define popcount __builtin_popcountll
string a[3000];
int row[3000], col[3000];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n,m; cin >> n >> m;
for (int i = 0; i < n; cin >> a[i++]);
long long ans = 0;
for (int i = n-1; i >= 0; i--) {
for (int j = m-1; j >= 0; j--) {
if (a[i][j] == 'J')
ans += row[i] * col[j];
else if (a[i][j] == 'O')
row[i]++;
else
col[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... |