Submission #858862

#TimeUsernameProblemLanguageResultExecution timeMemory
858862StefanSebezBitaro the Brave (JOI19_ho_t1)C++14
50 / 100
391 ms274432 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int n,m;cin>>n>>m; int a[n+1][m+1]; for(int i=1;i<=n;i++) { string s;cin>>s; for(int j=0;j<m;j++) { if(s[j]=='J') a[i][j+1]=0; if(s[j]=='O') a[i][j+1]=1; if(s[j]=='I') a[i][j+1]=2; } } int pref[3][n+1][m+1]; memset(pref,0,sizeof(pref)); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { for(int k=0;k<=2;k++) pref[k][i][j]=pref[k][i-1][j]+pref[k][i][j-1]-pref[k][i-1][j-1]; pref[a[i][j]][i][j]++; } } int res=0; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { if(a[i][j]!=0) continue; int x=pref[1][i][m]-pref[1][i-1][m]-pref[1][i][j]+pref[1][i-1][j]; int y=pref[2][n][j]-pref[2][n][j-1]-pref[2][i][j]+pref[2][i][j-1]; res+=x*y; } } cout<<res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...