제출 #394594

#제출 시각아이디문제언어결과실행 시간메모리
394594benedict0724Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
420 ms114884 KiB
#include <iostream> using namespace std; int v[3002][3002]; int dp[3002][3002]; int dp2[3002][3002]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int H, W; cin >> H >> W; for(int i=1;i<=H;i++) { string s; cin >> s; for(int j=1;j<=W;j++) { if(s[j-1] == 'J') v[i][j] = 1; if(s[j-1] == 'O') v[i][j] = 2; if(s[j-1] == 'I') v[i][j] = 3; } } for(int i=1;i<=H;i++) { for(int j=W;j>=1;j--) { dp[i][j] = dp[i][j+1]; if(v[i][j] == 2) dp[i][j]++; } } for(int j=1;j<=W;j++) { for(int i=H;i>=1;i--) { dp2[i][j] = dp2[i+1][j]; if(v[i][j] == 3) dp2[i][j]++; } } long long int ans = 0; for(int i=1;i<=H;i++) { for(int j=1;j<=W;j++) { if(v[i][j] == 1) ans += dp[i][j] * dp2[i][j]; } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...