Submission #720965

#TimeUsernameProblemLanguageResultExecution timeMemory
720965PringBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
326 ms184084 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> pii; const int MXN = 5005; int n, m, O[MXN][MXN], I[MXN][MXN], ans; string s[MXN]; char c[MXN][MXN]; void GO() { for (int i = 0; i < n; i++) { for (int j = m - 2; j >= 0; j--) { O[i][j] = O[i][j + 1]; if (s[i][j + 1] == 'O') O[i][j]++; } } } void GI() { for (int j = 0; j < m; j++) { for (int i = n - 2; i >= 0; i--) { I[i][j] = I[i + 1][j]; if (s[i + 1][j] == 'I') I[i][j]++; } } } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 0; i < n; i++) cin >> s[i]; GO(); GI(); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (s[i][j] != 'J') continue; ans += O[i][j] * I[i][j]; } } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...