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;
int a[3009][3009];
int b[3009][3009];
int c[3009][3009];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen(".INP","r",stdin);
// freopen(".OUT","w",stdout);
int n,m;
cin>>n>>m;
for (int i=1;i<=n;i++){
string s;
cin>>s;
for (int j=1;j<=m;j++){
if (s[j-1]=='J')a[i][j]=1;
else if (s[j-1]=='O')a[i][j]=2;
else a[i][j]=3;
}
}
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
b[i][j]=b[i][j-1];
if (a[i][j]==2)b[i][j]++;
}
}
for (int j=1;j<=m;j++){
for (int i=1;i<=n;i++){
c[i][j]=c[i-1][j];
if (a[i][j]==3)c[i][j]++;
}
}
long long ans=0;
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
if (a[i][j]==1)ans=ans+(b[i][m]-b[i][j])*(c[n][j]-c[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... |