Submission #261367

#TimeUsernameProblemLanguageResultExecution timeMemory
261367SpeedOfMagicBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
586 ms161840 KiB
#include "bits/stdc++.h" using namespace std; #define int long long signed main() { int h, w; cin >> h >> w; vector<string> s(h); for (int i = 0; i < h; ++i) cin >> s[i]; vector<vector<int>> cnt_o(h, vector<int>(w, 0)); vector<vector<int>> cnt_i(h, vector<int>(w, 0)); for (int i = h - 1; i >= 0; --i) { for (int j = 0; j < w; ++j) { cnt_i[i][j] = ((i + 1 < h) ? cnt_i[i + 1][j] : 0) + (s[i][j] == 'I'); } } for (int i = 0; i < h; ++i) { for (int j = w - 1; j >= 0; --j) { cnt_o[i][j] = ((j + 1 < w) ? cnt_o[i][j + 1] : 0) + (s[i][j] == 'O'); } } int ans = 0; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { ans += (s[i][j] == 'J') * cnt_i[i][j] * cnt_o[i][j]; } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...