Submission #853968

#TimeUsernameProblemLanguageResultExecution timeMemory
853968parsadox2Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
153 ms88660 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3e3 + 2; int h , w , dpo[N][N] , dpi[N][N]; char c[N][N]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> h >> w; for(int i = 0 ; i < h ; i++) for(int j = 0 ; j < w ; j++) cin >> c[i][j]; long long ans = 0; for(int i = h - 1 ; i >= 0 ; i--) for(int j = w - 1 ; j >= 0 ; j--) { dpi[i][j] = (i == h - 1 ? 0 : dpi[i + 1][j]); if(c[i][j] == 'I') dpi[i][j]++; dpo[i][j] = (j == w - 1 ? 0 : dpo[i][j + 1]); if(c[i][j] == 'O') dpo[i][j]++; if(c[i][j] == 'J') ans += dpi[i][j] * dpo[i][j]; } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...