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 <iostream>
#include <vector>
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
long long int h,w;
cin>>h>>w;
char grid[h][w];
int canti[h][w];
int canto[h][w];
vector<pair<int,int> > v;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
cin>>grid[i][j];
canti[i][j]=0;
canto[i][j]=0;
if(grid[i][j]=='J')v.push_back(make_pair(i,j));
if(grid[i][j]=='I'){
for(int x=i;x>=0;x--)canti[x][j]++;
}
if(grid[i][j]=='O'){
for(int x=j;x>=0;x--)canto[i][x]++;
}
}
}
int n=v.size();
long long int sol=0;
for(int j=0;j<n;j++){
int x=v[j].first,y=v[j].second;
sol+=canti[x][y]*canto[x][y];
}
cout<<sol<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |