Submission #391393

#TimeUsernameProblemLanguageResultExecution timeMemory
391393lukameladzeBitaro the Brave (JOI19_ho_t1)C++14
50 / 100
1094 ms75672 KiB
# include <bits/stdc++.h> #define f first #define s second #define pb push_back using namespace std; const int N=3005; long long n,m,ans,sf1[N][N],sf[N][N]; char ch[N][N]; int main() { cin>>n>>m; for(int i=1; i<=n; i++) { for (int j=1; j<=m; j++) { cin>>ch[i][j]; } } for (int i=1; i<=n; i++) { for (int j=m; j>=1; j--) { sf[i][j]=sf[i][j+1]+(ch[i][j]=='O'); } } for (int j=1; j<=m; j++) { for (int i=n; i>=1; i--) { sf1[i][j]=sf1[i+1][j]+(ch[i][j]=='I'); } } //cout<<sf[1][2]<<endl; // cout<<sf1[2][1]; for (int i=1; i<=n; i++) { for (int j=1; j<=m; j++) { if (ch[i][j]!='J') continue; ans+=sf[i][j+1]*sf1[i+1][j]; } } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...