Submission #851995

#TimeUsernameProblemLanguageResultExecution timeMemory
851995stdfloatBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
97 ms89680 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int32_t main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; vector<string> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<vector<int>> cntI(n, vector<int>(m)), cntO(n, vector<int>(m)); for (int i = n - 1; i >= 0; i--) { for (int j = m - 1; j >= 0; j--) { cntI[i][j] += (i + 1 < n ? cntI[i + 1][j] : 0) + (a[i][j] == 'I'); cntO[i][j] += (j + 1 < m ? cntO[i][j + 1] : 0) + (a[i][j] == 'O'); } } ll ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m - 1; j++) { if (a[i][j] == 'J') ans += 1LL * cntO[i][j] * cntI[i][j]; } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...