# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
678781 | hello_there_123 | Bitaro the Brave (JOI19_ho_t1) | C++17 | 624 ms | 159172 KiB |
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
main(){
int n,m;
cin>>n>>m;
char arr[n+3][m+3];
int O[n+3][m+3];
int I[n+3][m+3];
memset(O,0,sizeof(O));
memset(I,0,sizeof(I));
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>arr[i][j];
}
}
for(int i=0;i<n;i++){
for(int j=m-1;j>=0;j--){
if(arr[i][j]!='O'){
O[i][j] = O[i][j+1];
continue;
}
if(j==m-1) O[i][j] = 1;
else O[i][j] = O[i][j+1]+1;
}
}
for(int i=n-1;i>=0;i--){
for(int j=0;j<m;j++){
if(arr[i][j]!='I'){
I[i][j] = I[i+1][j];
continue;
}
if(i==n-1) I[i][j] = 1;
else I[i][j] = I[i+1][j]+1;
}
}
int sum = 0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(arr[i][j] == 'J'){
sum+=O[i][j]*I[i][j];
}
}
}
cout<<sum;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |