This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ld long double
#define fi first
#define se second
#define ll long long
#define ss(x) (int) x.size()
#define mp make_pair
#define FOR(i, n) for(int i = 1; n >= i; ++i)
using namespace std;
using namespace __gnu_pbds;
const int nax = 5005;
int n, m;
string s[nax];
int dol[nax][nax], prawo[nax][nax];
ll ans = 0;
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
cin >> n >> m;
for(int i = 0; i < n; ++i) {
cin >> s[i];
}
for(int i = m - 1; 0 <= i; --i) {
for(int j = 0; j < n; ++j) {
prawo[j][i] = prawo[j][i + 1] + (s[j][i + 1] == 'O');
}
}
for(int i = n - 1; 0 <= i; --i) {
for(int j = 0; j < m; ++j) {
dol[i][j] = dol[i + 1][j] + (s[i + 1][j] == 'I');
}
}
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j) {
ans += (dol[i][j] * prawo[i][j] * (s[i][j] == 'J'));
}
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |