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(){
int h,w;
cin>>h>>w;
char grid[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];
if(grid[i][j]=='J')v.push_back(make_pair(i,j));
}
}
int n=v.size();
int sol=0;
for(int j=0;j<n;j++){
//cout<<sol<<' ';
int x=v[j].first;
int y=v[j].second;
//cout<<x<<' '<<y<<' ';
int co=0,ci=0;
for(int i=x;i<h;i++){
if(grid[i][y]=='I')co++;
//cout<<grid[i][y]<<' ';
}
for(int i=y;i<w;i++){
if(grid[x][i]=='O')ci++;
// cout<<grid[x][i]<<' ';
}
//cout<<co<<' '<<ci<<' ';
sol+=co*ci;
}
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... |