Submission #776212

#TimeUsernameProblemLanguageResultExecution timeMemory
776212DobromirAngelovBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
245 ms89488 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; const int MAXN=3005; int n,m; string s[MAXN]; int pref[2][MAXN][MAXN]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n>>m; for(int i=0;i<n;i++) { cin>>s[i]; } for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { if(j>0) pref[0][i][j]=pref[0][i][j-1]; if(s[i][j]=='O') pref[0][i][j]++; } } for(int j=0;j<m;j++) { for(int i=0;i<n;i++) { if(i>0) pref[1][i][j]=pref[1][i-1][j]; if(s[i][j]=='I') pref[1][i][j]++; } } long long ans=0; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { if(s[i][j]=='J') ans+=(pref[0][i][m-1]-(j>0 ? pref[0][i][j-1] : 0)) * (pref[1][n-1][j]-(i>0 ? pref[1][i-1][j] : 0)); } } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...