# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1258752 | trgbao | Bitaro the Brave (JOI19_ho_t1) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
string a[3005];
int fi[3005][3005];
int fo[3005][3005];
sined main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
for (int i = 1;i <= n;i++) {
cin >> a[i];
string s = " ";
a[i] = s + a[i];
}
for (int i = 1;i<=n;i++){
for (int j = 1; j <= m;j++) {
fo[i][j] = fo[i][j-1] + (a[i][j] == 'O');
fi[i][j] = fi[i-1][j] + (a[i][j] == 'I');
// cout << i << " " << j << '\n';
// cout << fo[i][j] << " " << fi[i][j] << '\n';
}
}
int res = 0;
for (int i = 1;i<=n;i++) {
for (int j = 1;j<=m;j++) {
if (a[i][j] == 'J') res += (fi[n][j] - fi[i][j]) * (fo[i][m] - fo[i][j]);
// cout << fi[n][j] - fi[i][j] << " " << fo[i][m] - fo[i][j] << '\n';
}
}
cout << res;
return 0;
}