Submission #1251202

#TimeUsernameProblemLanguageResultExecution timeMemory
1251202antonnBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
146 ms80132 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; template<typename T> bool assign_min(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<typename T> bool assign_max(T& a, T b) { if (a < b) { a = b; return true; } return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; vector<vector<char>> a(n + 2, vector<char>(m + 2)); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; } } vector<vector<int>> down(n + 2, vector<int>(m + 2)); vector<vector<int>> right(n + 2, vector<int>(m + 2)); for (int i = n; i >= 1; i--) { for (int j = m; j >= 1; j--) { down[i][j] = down[i + 1][j] + (a[i][j] == 'I'); right[i][j] = right[i][j + 1] + (a[i][j] == 'O'); } } ll ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (a[i][j] == 'J') { ans += (ll) down[i][j] * right[i][j]; } } } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...