제출 #651454

#제출 시각아이디문제언어결과실행 시간메모리
651454pauloamedBitaro the Brave (JOI19_ho_t1)C++14
50 / 100
85 ms4776 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int MAXN = 510; char M[MAXN][MAXN]; int Os[MAXN][MAXN]; int Is[MAXN][MAXN]; int32_t main(){ int h, w; cin >> h >> w; for(int i = 0; i < h; ++i){ for(int j = 0; j < w; ++j){ cin >> M[i][j]; } } for(int i = 0; i < h; ++i){ for(int j = w - 1; j >= 0; --j){ Os[i][j] = (M[i][j] == 'O'); if(j + 1 < w) Os[i][j] += Os[i][j + 1]; } } for(int j = 0; j < w; j++){ for(int i = h - 1; i >= 0; --i){ Is[i][j] = (M[i][j] == 'I'); if(i + 1 < h) Is[i][j] += Is[i + 1][j]; } } int ans = 0; for(int i = 0; i < h; ++i){ for(int j = 0; j < w; ++j){ if(M[i][j] == 'J'){ int x = Is[i][j] * Os[i][j]; ans += x; } } } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...