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;
char ma[3001][3001];
vector <pair<long long,long long >> di;
int main(){
long long n,m,i,j,ans=0;
cin>>n>>m;
string s;
for( i=0;i<n;i++){
cin>>s;
for( j=0;j<m;j++)
ma[i][j]=s[j];
}
for(i=0;i<n;i++){
for(int j=0;j<m;j++){
if(ma[i][j]=='J')
di.push_back({i,j});
}
}
for(pair<int,int> x:di){
long long tw=x.first;
long long on=x.second;
long long s1=0,s2=0;
for(i=on+1;i<m;i++){
if(ma[tw][i]=='O')
s1++;
}
for(i=tw+1;i<n;i++){
if(ma[i][on]=='I')
s2++;
}
ans+=s1*s2;
}
cout<<ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |