Submission #786769

#TimeUsernameProblemLanguageResultExecution timeMemory
786769winter0101Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
302 ms115116 KiB
#include <bits/stdc++.h> using namespace std; int a[3009][3009]; int b[3009][3009]; int c[3009][3009]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); //freopen(".INP","r",stdin); // freopen(".OUT","w",stdout); int n,m; cin>>n>>m; for (int i=1;i<=n;i++){ string s; cin>>s; for (int j=1;j<=m;j++){ if (s[j-1]=='J')a[i][j]=1; else if (s[j-1]=='O')a[i][j]=2; else a[i][j]=3; } } for (int i=1;i<=n;i++){ for (int j=1;j<=m;j++){ b[i][j]=b[i][j-1]; if (a[i][j]==2)b[i][j]++; } } for (int j=1;j<=m;j++){ for (int i=1;i<=n;i++){ c[i][j]=c[i-1][j]; if (a[i][j]==3)c[i][j]++; } } long long ans=0; for (int i=1;i<=n;i++){ for (int j=1;j<=m;j++){ if (a[i][j]==1)ans=ans+(b[i][m]-b[i][j])*(c[n][j]-c[i][j]); } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...