제출 #897197

#제출 시각아이디문제언어결과실행 시간메모리
897197aqxaBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
164 ms89628 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3003; int cx[N][N], cy[N][N], n, m; string g[N]; int32_t main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m; for (int i = 0; i < n; ++i) cin >> g[i]; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cx[i][j] = cy[i][j] = 0; } } for (int i = 0; i < n; ++i) { for (int j = m - 1; j >= 0; --j) { cx[i][j] += cx[i][j + 1]; if (g[i][j] == 'O') cx[i][j]++; } } for (int j = 0; j < m; ++j) { for (int i = n - 1; i >= 0; --i) { cy[i][j] += cy[i + 1][j]; if (g[i][j] == 'I') cy[i][j]++; } } ll ans = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (g[i][j] == 'J') { ans += cx[i][j] * cy[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...