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 main(){
int h, w;
vector<string> grid;
cin >> h >> w;
for(int i=0; i<h; i++){
string a;
cin >> a;
grid.push_back(a);
}
int sumO[3010][3010]={}, sumI[3010][3010]={};
for(int i=h-1; i>=0; i--){
for(int j=w-1; j>=0; j--){
sumO[i][j]=sumO[i][j+1];
if(grid[i][j]=='O')sumO[i][j]++;
sumI[i][j]=sumI[i+1][j];
if(grid[i][j]=='I')sumI[i][j]++;
}
}
long long resp=0;
for(int i=0; i<h; i++){
for(int j=0; j<w; j++){
if(grid[i][j]!='J')continue;
resp+=(long long)sumO[i][j]*sumI[i][j];
}
}
cout << resp << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |