Submission #574054

#TimeUsernameProblemLanguageResultExecution timeMemory
574054luka1234Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
843 ms152904 KiB
#include <bits/stdc++.h> #define ll long long #define ff first #define ss second #define db double using namespace std; ll n,m; ll pref1[3001][3001]; ll pref2[3001][3001]; string s[3001]; int main(){ cin>>n>>m; for(ll i=1;i<=n;i++){ s[i].push_back('@'); for(ll j=1;j<=m;j++){ char c; cin>>c; s[i].push_back(c); } } for(ll i=1;i<=n;i++){ for(ll j=1;j<=m;j++){ pref1[i][j]=pref1[i][j-1]; if(s[i][j]=='O') pref1[i][j]++; } } for(ll j=1;j<=m;j++){ for(ll i=1;i<=n;i++){ pref2[i][j]=pref2[i-1][j]; if(s[i][j]=='I') pref2[i][j]++; } } ll ans=0; for(ll i=1;i<=n;i++){ for(ll j=1;j<=m;j++){ if(s[i][j]!='J') continue; ll r1=pref1[i][m]-pref1[i][j-1]; ll r2=pref2[n][j]-pref2[i-1][j]; ans+=r1*r2; } } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...