Submission #996439

#TimeUsernameProblemLanguageResultExecution timeMemory
996439yanbBitaro the Brave (JOI19_ho_t1)C++14
0 / 100
0 ms604 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<long long, long long> #define t3i tuple<long long, long long, long long> signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; vector<vector<char>> a(n, vector<char>(m)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; } } vector<vector<int>> os(n, vector<int>(m + 1)), is(n + 1, vector<int>(m)); for (int i = 0; i < n; i++) { for (int j = m - 1; j >= 0; j--) { os[i][j] = os[i][j + 1] + (a[i][j] == 'O'); } } for (int j = 0; j < m; j++) { for (int i = n - 1; i >= 0; i--) { is[i][j] = is[i + 1][j] + (a[i][j] == 'I'); } } int ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i][j] == 'J') { ans += os[i][j] * is[i][j]; } } } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...