Submission #623203

#TimeUsernameProblemLanguageResultExecution timeMemory
623203Abrar_Al_SamitBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
364 ms159012 KiB
#include<bits/stdc++.h> using namespace std; void PlayGround() { int n, m; cin>>n>>m; char c[n+2][m+2]; for(int i=1; i<=n; ++i) { for(int j=1; j<=m; ++j) { cin>>c[i][j]; } } long long O[n+2][m+2]; long long I[n+2][m+2]; memset(O, 0, sizeof O); memset(I, 0, sizeof I); for(int i=1; i<=n; ++i) { for(int j=1; j<=m; ++j) { if(c[i][j]=='O') O[i][j] = 1; else if(c[i][j]=='I') I[i][j] = 1; } } for(int i=1; i<=n; ++i) { for(int j=m; j>0; --j) { O[i][j] += O[i][j+1]; } } for(int j=1; j<=m; ++j) { for(int i=n; i>0; --i) { I[i][j] += I[i+1][j]; } } long long ans = 0; for(int i=1; i<=n; ++i) { for(int j=1; j<=m; ++j) if(c[i][j]=='J') { ans += O[i][j+1] * I[i+1][j]; } } cout<<ans<<'\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); PlayGround(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...