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 <bits/stdc++.h>
using namespace std;
typedef long long int llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl "\n"
llo mod=1000000007;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
//setIO("");
llo n,m;
cin>>n>>m;
char ss;
llo it[n][m];
for(llo i=0;i<n;i++){
for(llo j=0;j<m;j++){
cin>>ss;
if(ss=='J'){
it[i][j]=0;
}
else if(ss=='O'){
it[i][j]=1;
}
else{
it[i][j]=2;
}
}
}
llo pre[n][m];
for(llo i=0;i<n;i++){
for(llo j=m-1;j>=0;j--){
llo cc=0;
if(it[i][j]==1){
cc=1;
}
pre[i][j]=cc;
if(j<m-1){
pre[i][j]+=pre[i][j+1];
}
}
}
llo pre2[n][m];
for(llo j=0;j<m;j++){
for(llo i=n-1;i>=0;i--){
llo cc=0;
if(it[i][j]==2){
cc=1;
}
pre2[i][j]=cc;
if(i<n-1){
pre2[i][j]+=pre2[i+1][j];
}
}
}
llo tot=0;
for(llo i=0;i<n;i++){
for(llo j=0;j<m;j++){
if(it[i][j]==0){
tot+=pre[i][j]*pre2[i][j];
}
}
}
cout<<tot<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |