Submission #713270

#TimeUsernameProblemLanguageResultExecution timeMemory
713270ln_eBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
315 ms88512 KiB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho using ll=long long; using ld=long double; int const INF=1000000005; ll const LINF=1000000000000000005; ll const mod=1000000007; ld const PI=3.14159265359; ll const MAX_N=3e5+5; ld const EPS=0.00000001; #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #define f first #define s second #define pb push_back #define mp make_pair #define endl '\n' #define sz(a) (int)a.size() #define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; ll n,sum1[3005][3005],sum2[3005],m; char a[3005][3005]; int32_t main(){ CODE_START; #ifdef LOCAL ifstream cin("input.txt"); #endif cin>>n>>m; for(ll i=1;i<=n;i++) { for(ll j=1;j<=m;j++) { cin>>a[i][j]; } } for(ll j=1;j<=m;j++) { ll sum=0; for(ll i=n;i>=1;i--) { if(a[i][j]=='I'){ sum++; }else if(a[i][j]=='J'){ sum1[i][j]=sum; } } } ll ans=0; for(ll i=1;i<=n;i++) { ll sum=0; for(ll j=1;j<=m;j++) { //cout<<sum1[i][j]<<' '; if(a[i][j]=='J'){ sum+=sum1[i][j]; }else if(a[i][j]=='O'){ ans+=sum; } } //cout<<endl; } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...