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;
#define int long long
typedef pair<int,int>pii;
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);
int r,c;
cin >> r >> c;
char arr[r+5][c+5];
for(int x=1;x<=r;x++){
for(int y=1;y<=c;y++){
cin >> arr[x][y];
}
}
//compute psum
int horizontal[r+5][c+5];
memset(horizontal,0,sizeof(horizontal));
for(int x=1;x<=r;x++){
for(int y=c;y>=1;y--){
horizontal[x][y]=horizontal[x][y+1]+(arr[x][y]=='O');
}
}
int vertical[r+5][c+5];
memset(vertical,0,sizeof(vertical));
for(int x=1;x<=c;x++){
for(int y=r;y>=1;y--){
vertical[y][x]=vertical[y+1][x]+(arr[y][x]=='I');
}
}
int counter=0;
for(int x=1;x<=r;x++){
for(int y=1;y<=c;y++){
if(arr[x][y]=='J'){
counter+=horizontal[x][y]*vertical[x][y];
}
}
}
cout << counter;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |