제출 #1280152

#제출 시각아이디문제언어결과실행 시간메모리
1280152ducanh0811Bitaro the Brave (JOI19_ho_t1)C++20
100 / 100
216 ms150404 KiB
#include <bits/stdc++.h> #define int long long #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define REV(i, a, b) for (int i = (a), _b = (b); i >= _b; --i) using namespace std; #define MAXN 3005 char a[MAXN][MAXN]; int prefO[MAXN][MAXN]; int prefI[MAXN][MAXN]; int n, m; void solve() { cin >> n >> m; FOR(i, 1, n){ FOR(j, 1, m){ cin >> a[i][j]; } } FOR(i, 1, n) { REV(j, m, 1){ prefO[i][j] = prefO[i][j + 1]; if (a[i][j] == 'O') prefO[i][j]++; } } REV(i, n, 1){ FOR(j, 1, m){ prefI[i][j] = prefI[i + 1][j]; if (a[i][j] == 'I') prefI[i][j]++; } } int res = 0; FOR(i, 1, n){ FOR(j, 1, m){ if (a[i][j] == 'J'){ res += (prefO[i][j] * prefI[i][j]); } } } cout << res; } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...