Submission #851251

#TimeUsernameProblemLanguageResultExecution timeMemory
851251askowBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
384 ms159112 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main(){ ios::sync_with_stdio(false); cin.tie(0); int n,m; cin>>n>>m; char a[n+1][m+1]; for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin>>a[i][j]; int ans=0; int suf[n+1][m+2]; for(int i=0;i<=n;i++)for(int j=0;j<=m+1;j++)suf[i][j]=0; for(int i=1;i<=n;i++){ for(int j=m;j>=1;j--){ suf[i][j]=suf[i][j+1]; if(a[i][j]=='O')suf[i][j]++; } } int dp[n+2][m+2]; for(int i=0;i<=n+1;i++)for(int j=0;j<=m+1;j++)dp[i][j]=0; for(int i=1;i<=m;i++){ for(int j=n;j>=1;j--){ dp[j][i]=dp[j+1][i]; if(a[j][i]=='I')dp[j][i]++; } } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(a[i][j]=='J'){ int Z=dp[i+1][j]; int R=suf[i][j+1];/* for(int k=i+1;k<=n;k++){ if(a[k][j]=='I')Z++; }*/ /* for(int k=j+1;k<=m;k++){ if(a[i][k]=='O')R++; }*/ ans+=Z*R; } } } cout<<ans; } // bitset fora?
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...