Submission #209871

#TimeUsernameProblemLanguageResultExecution timeMemory
209871sevlllBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
380 ms160184 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define ld long double signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, m; cin >> n >> m; vector<string> A(n); for (int i = 0; i < n; i++) cin >> A[i]; int ans = 0; vector<vector<int>> suf_o(n + 1, vector<int>(m+1)); vector<vector<int>> stolb_i(n + 1, vector<int>(m+1)); for (int i = 0; i < n; i++) { suf_o[i][m-1] = (A[i][m-1] == 'O'); for (int j = m - 2; j >= 0; j--) { suf_o[i][j] = (A[i][j]=='O') + suf_o[i][j+1]; } } for (int j = 0; j < m; j++) { stolb_i[n-1][j] = (A[n-1][j] == 'I'); for (int i = n - 2; i >= 0; i--) { stolb_i[i][j] = stolb_i[i+1][j] + (A[i][j] == 'I'); } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (A[i][j] == 'J') { ans += suf_o[i][j+1] * stolb_i[i+1][j]; } } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...