Submission #1306348

#TimeUsernameProblemLanguageResultExecution timeMemory
1306348khanhphucscratchBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
311 ms150412 KiB
#include<bits/stdc++.h> #define int long long using namespace std; int cd[2][3005][3005]; char a[3005][3005]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin>>n>>m; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cin>>a[i][j]; if(a[i][j] == 'O') cd[0][i][j] = 1; if(a[i][j] == 'I') cd[1][i][j] = 1; } } for(int i = 1; i <= n; i++){ for(int j = m; j >= 1; j--) cd[0][i][j] += cd[0][i][j+1]; } for(int j = 1; j <= m; j++){ for(int i = n; i >= 1; i--) cd[1][i][j] += cd[1][i+1][j]; } int ans = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++) if(a[i][j] == 'J') ans += cd[0][i][j] * cd[1][i][j]; } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...