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>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back
void solve() {
int n,m;
cin>>n>>m;
string a[n];
for(int i=0;i<n;i++)cin>>a[i];
ll ans=0,c1[n+1][m+1],c2[n+1][m+1];
memset(c1,0,sizeof(c1));
memset(c2,0,sizeof(c2));
for(int i=n-1;i>-1;i--){
for(int j=m-1;j>-1;j--){
c1[i][j]=c1[i+1][j]+(a[i][j]=='I');
c2[i][j]=c2[i][j+1]+(a[i][j]=='O');
if(a[i][j]=='J')ans+=c1[i+1][j]*c2[i][j+1];
}
}
cout<<ans;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |