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
#define endl '\n'
signed main(){
int h, w; cin >> h >> w;
char g[h][w];
for(int i=0; i<h; i++){
string s; cin >> s;
for(int j=0; j<w; j++){
g[i][j]= s[j];
}
}
int c1[h][w];
for(int i=0; i<h; i++){
int count= 0;
for(int j=w-1; j>=0; j--){
if(g[i][j]=='J'){c1[i][j]= count;}
else{c1[i][j]= 0;}
if(g[i][j]=='O'){count++;}
}
}
int c2[h][w];
for(int i=0; i<w; i++){
int countt= 0;
for(int j=h-1; j>=0; j--){
if(g[j][i]=='J'){c2[j][i]= countt;}
else{c2[j][i]= 0;}
if(g[j][i]=='I'){countt++;}
}
}
int ans= 0;
for(int i=0; i<h; i++){
for(int j=0; j<w; j++){
ans+= (c1[i][j]*c2[i][j]);
}
}
cout << ans << 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... |