Submission #878693

#TimeUsernameProblemLanguageResultExecution timeMemory
878693frostray8653Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
199 ms89164 KiB
#include <bits/stdc++.h> #define int long long #define IO ios::sync_with_stdio(0), cin.tie(0) #define FOR(i, a, b) for (int i = a, I = b; i <= I; i++) using namespace std; using pii = pair<int, int>; void dbg() {;} template<class T, class ...U> void dbg(T a, U ...b) { cout << a << " "; dbg(b...); } void ent() { cout << "\n"; } const int N = 3005; char a[N][N]; int j_sum[N][N]; signed main() { IO; int n, m; cin >> n >> m; FOR(i, 1, n) FOR(j, 1, m) cin >> a[i][j]; for (int i = 1; i <= n; i++) { int O_cnt = 0; for (int j = m; j >= 1; j--) { if (a[i][j] == 'O') O_cnt += 1; else if (a[i][j] == 'J') j_sum[i][j] = O_cnt; } } int ans = 0; for (int j = 1; j <= m; j++) { for (int i = 1; i <= n; i++) { j_sum[i][j] += j_sum[i - 1][j]; if (a[i][j] == 'I') ans += j_sum[i][j]; } } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...