Submission #922227

#TimeUsernameProblemLanguageResultExecution timeMemory
922227AiperiiiBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
312 ms159828 KiB
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() using namespace std; const int N=3005; char a[N][N]; int cntO[N][N],cntI[N][N]; signed main(){ ios_base::sync_with_stdio(); cin.tie(0);cout.tie(0); int h,w; cin>>h>>w; char a[h][w]; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin>>a[i][j]; } } for(int i=0;i<h;i++){ int cnt=0; for(int j=w-1;j>=0;j--){ if(a[i][j]=='O')cnt++; cntO[i][j]=cnt; } } for(int i=0;i<w;i++){ int cnt=0; for(int j=h-1;j>=0;j--){ if(a[j][i]=='I')cnt++; cntI[j][i]=cnt; } } int ans=0; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(a[i][j]=='J')ans+=cntI[i][j]*cntO[i][j]; } } cout<<ans<<"\n"; } /* 3 4 JOIJ JIOO IIII 4 4 JJOO JJOO IIJO IIIJ */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...