Submission #236925

#TimeUsernameProblemLanguageResultExecution timeMemory
236925priyansh5525Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
347 ms159884 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long int #define pii pair<long long int,long long int> #define vi vector<long long int > #define vvi vector<vector< long long int>> #define MP make_pair #define PB push_back #define pb pop_back #define PF push_front #define pf pop_front #define MOD 1000000007 #define MT make_tuple ll n,m,r[3001][3001],c[3001][3001]; ll ans = 0; string s[3001]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n>>m; for(ll i=0;i<n;i++) { cin>>s[i]; } for(ll i=0;i<n;i++) { for(ll j=0;j<m;j++) { r[i][j]=0; c[i][j]=0; if(s[i][j]=='O') r[i][j]++; if(s[i][j]=='I') c[i][j]++; } r[i][m]=0; } for(ll j=0;j<m;j++) c[n][j]=0; for(ll i=0;i<n;i++) { for(ll j=m-1;j>=0;j--) { r[i][j]+=r[i][j+1]; } } for(ll j=0;j<m;j++) { for(ll i=n-1;i>=0;i--) c[i][j]+=c[i+1][j]; } for(ll i=0;i<n;i++) { for(ll j=0;j<m;j++) { if(s[i][j]=='J') ans+=r[i][j]*c[i][j]; } } cout<<ans<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...