Submission #1172962

#TimeUsernameProblemLanguageResultExecution timeMemory
1172962nguyenkhangninh99Bitaro the Brave (JOI19_ho_t1)C++20
100 / 100
249 ms150740 KiB
#include <bits/stdc++.h> using namespace std; #define int long long void solve(){ int n, m; cin >> n >> m; vector<vector<char>> c(n + 2, vector<char>(m + 2)); vector<vector<int>> cnto(n + 2, vector<int>(m + 2)), cnti(n + 2, vector<int>(m + 2)); for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cin >> c[i][j]; if(c[i][j] == 'O') cnto[i][j] = 1; if(c[i][j] == 'I') cnti[i][j] = 1; } } int ans = 0; for(int i = n; i >= 1; i--){ for(int j = m; j >= 1; j--) cnti[i][j] += cnti[i + 1][j]; for(int j = m; j >= 1; j--) cnto[i][j] += cnto[i][j + 1]; for(int j = m; j >= 1; j--) ans += cnto[i][j] * cnti[i][j] * (c[i][j] == 'J'); } cout << ans; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...