This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// In the name of God
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;
#define pb push_back
#define S second
#define F first
#define mp make_pair
#define smax(x, y) (x) = max((x), (y))
#define smin(x, y) (x) = min((x), (y))
#define all(x) (x).begin(), (x).end()
#define len(x) ((ll)(x).size())
const int maxn = 3000 + 5;
const int inf = 1e9 + 7;
int n, m, orb[maxn][maxn], ing[maxn][maxn];
string a[maxn];
int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n; i++){
for(int j = m - 1; j >= 0; j--)
orb[i][j] = orb[i][j + 1] + (a[i][j] == 'O');
}
ll ans = 0;
for(int j = 0; j < m; j++){
for(int i = n - 1; i >= 0; i--){
ing[i][j] = ing[i + 1][j] + (a[i][j] == 'I');
if(a[i][j] == 'J') ans += ing[i][j] * orb[i][j];
}
}
cout << ans << '\n';
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... |