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;
vector<string> tb;
const int N=3e3+10;
int o[N][N];
int e[N][N];
int main(){
int h,w;
cin>>h >>w;
tb.resize(h);
for(int i=0;i<h;i++){
cin>>tb[i];
}
//cout<<1;
for(int i=0;i<h;i++){
for(int j=w-1;j>=0;j--){
o[i][j]=o[i][j+1];
if(tb[i][j]=='O') o[i][j]++;
}
}
//cout<<2;
for(int i=h-1;i>=0;i--){
//cout<<4;
for(int j=0;j<w;j++){
//cout<<5;
e[i][j]=e[i+1][j];
if(tb[i][j]=='I') e[i][j]++;
}
}
//cout<<3;
int sum=0;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(tb[i][j]=='J') sum+=(o[i][j+1]*e[i+1][j]);
}
}
cout<<sum;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |