This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define nikah ios_base::sync_with_stdio(0); cin.tie(0);
const ll maxn = 3e3+7;
using namespace std;
ll t,n,m;
char a[maxn][maxn];
ll pref1[maxn][maxn], pref2[maxn][maxn];
int main () {
nikah
cin>>n>>m;
for (ll i=1; i<=n; i++) {
for (ll j=1; j<=m; j++) {
cin>>a[i][j];
}
}
ll ans = 0;
for (ll i=1; i<=n; i++) {
for (ll j=m; j>=1; j--) {
if (a[i][j] == 'O') pref1[i][j]++;
pref1[i][j] += pref1[i][j+1];
}
}
for (ll j=1; j<=m; j++) {
for (ll i=n; i>=1; i--) {
if (a[i][j] == 'I') pref2[i][j]++;
pref2[i][j] += pref2[i+1][j];
}
}
for (ll i=1; i<=n; i++) {
for (ll j=1; j<=m; j++) {
if (a[i][j] == 'J') {
ans += (pref1[i][j] * pref2[i][j]);
}
}
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |