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 all(v) ((v).begin(),(v).end())
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;
const ll mxN = 2e6 + 1;
char a[3011][3011];
ll ing[3011][3011],orb[3011][3011];
signed main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n,m;
cin >>n>>m;
for(ll i = 1;i <= n;i++){
for(ll j = 1; j <= m;j++){
cin >>a[i][j];
}
}
for(ll j = 1;j <= m;j++){
for(ll i = n;i;i--){
ing[i][j] = ing[i + 1][j] + (a[i][j] == 'I');
}
}
for(ll i = 1;i <= n;i++){
for(ll j = m;j;j--){
orb[i][j] = orb[i][j + 1] + (a[i][j] == 'O');
}
}
ll ans = 0;
for(ll i = 1;i<= n;i++){
for(ll j = 1;j <= m;j++){
if(a[i][j] == 'J'){
ans += orb[i][j] * ing[i][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... |