Submission #261369

#TimeUsernameProblemLanguageResultExecution timeMemory
261369SpeedOfMagicBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
180 ms151624 KiB
#include "bits/stdc++.h" using namespace std; #define int long long signed main() { ios::sync_with_stdio(0); cin.tie(); 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...