Submission #927231

#TimeUsernameProblemLanguageResultExecution timeMemory
927231Gromp15Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
81 ms50068 KiB
#include <bits/stdc++.h> #define ll long long #define ar array #define db double #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define rint(l, r) uniform_int_distribution<int>(l, r)(rng) template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } void test_case() { int n, m; cin >> n >> m; vector<string> a(n); for (auto &x : a) cin >> x; vector<vector<int>> suff(n, vector<int>(m)); for (int i = n-1; i >= 0; i--) { for (int j = 0; j < m; j++) { suff[i][j] = (a[i][j] == 'I') + (i+1 < n ? suff[i+1][j] : 0); } } ll ans = 0; for (int i = 0; i < n; i++) { int cnt = 0; for (int j = m-1; j >= 0; j--) { if (a[i][j] == 'O') cnt++; else if (a[i][j] == 'J') { ans += cnt * suff[i][j]; } } } cout << ans << '\n'; } int main() { cin.tie(0)->sync_with_stdio(0); int t = 1; // cin >> t; while (t--) test_case(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...