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
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int h,w;
cin>>h>>w;
char g[h+5][w+5];
for(int i=1; i<=h; i++){
for(int j=1; j<=w; j++){
cin>>g[i][j];
}
}
int so[h+5][w+5], si[h+5][w+5];
memset(so,0,sizeof(so)); memset(si,0,sizeof(si));
//Orb: sec is higher; Ingot: fst is higher
for(int i=1; i<=h; i++){
for(int j=w; j>=1; j--){
so[i][j] = so[i][j+1];
if(g[i][j]=='O') so[i][j]++;
}
}
for(int i=h; i>=1; i--){
for(int j=1; j<=w; j++){
si[i][j]=si[i+1][j];
if(g[i][j]=='I') si[i][j]++;
}
}
int an=0;
for(int i=1; i<=h; i++){
for(int j=1; j<=w; j++){
if(g[i][j]=='J') an += (so[i][j]*si[i][j]);
}
}
cout<<an;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |