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 SZ 3005
using namespace std;
int h,w,rowo[SZ][SZ],coli[SZ][SZ];
int main() {
long long sum=0;
vector<pair<int,int> >coords;
string s;
cin>>h>>w;
for(int i=1;i<=h;i++){
cin>>s;
for(int j=1;j<=w;j++){
rowo[i][j]=rowo[i][j-1];
coli[i][j]=coli[i-1][j];
if(s[j-1]=='J')coords.emplace_back(i,j);
else if(s[j-1]=='O')rowo[i][j]++;
else if(s[j-1]=='I')coli[i][j]++;
}
}
/* for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
cout<<rowo[i][j]<<" ";
}
cout<<"\n";
}
cout<<"\n";
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
cout<<coli[i][j]<<" ";
}
cout<<"\n";
}*/
for(auto x:coords){
sum+=(rowo[x.first][w]-rowo[x.first][x.second])*(coli[h][x.second]-coli[x.first][x.second]);
}
cout<<sum;
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... |