Submission #678781

#TimeUsernameProblemLanguageResultExecution timeMemory
678781hello_there_123Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
624 ms159172 KiB
#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)

joi2019_ho_t1.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...