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 int long long
using namespace std;
int prefo[3000][3000];
int prefi[3000][3000];
signed main()
{
int n,m;
cin>>n>>m;
char a[n][m];
for(int i=0; i < n; i++)
for(int j=0; j < m;j++)
cin >> a[i][j];
for(int i=0; i<n;i++) {
for(int j=0; j<m; j++) {
if(a[i][j] == 'I'){
prefi[i][j]++;
}
if(a[i][j] == 'O'){
prefo[i][j]++;
}
}
}
for(int i=0; i < n; i++){
for(int j=0; j < m;j++){
prefo[i][j] += prefo[i][j - 1];
}
}
for(int i=0; i < n; i++){
for(int j=0; j < m;j++){
prefi[i][j] += prefi[i - 1][j];
}
}
long long rez=0;
long long brI=0;
long long brO=0;
/* for(int i=0; i < n; i++){
for(int j=0; j < m;j++){
cout<<prefi[i][j]<< " ";
}
cout<<"\n";
}
cout<<"\n";
for(int i=0; i < n; i++){
for(int j=0; j < m;j++){
cout<<prefo[i][j]<< " ";
}
cout<<"\n";
}
cout<<"\n";*/
for(int i=0; i < n; i++){
for(int j=0; j < m;j++){
if(a[i][j]=='J'){
brI = prefi[n-1][j] - prefi[i][j];
brO = prefo[i][m-1] - prefo[i][j];
rez+=brI*brO;
}
}
}
cout<<rez;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |