Submission #851250

#TimeUsernameProblemLanguageResultExecution timeMemory
851250askowBitaro the Brave (JOI19_ho_t1)C++14
50 / 100
1030 ms83624 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 pref[n+1]; for(int i=0;i<=n;i++)pref[i]=0; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(a[i][j]=='I')pref[i]++; } } 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]++; } } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(a[i][j]=='J'){ int Z=0; int R=0; 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...