# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133282 | osaaateiasavtnl | Bitaro the Brave (JOI19_ho_t1) | C++14 | 298 ms | 159048 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 3001;
char a[N][N];
vector <char> al = {'J', 'O', 'I'};
int get(char c) {
for (int i = 0; i < 3; ++i) {
if (al[i] == c) return i;
}
}
int row[N][N], col[N][N];
signed main() {
#ifdef HOME
freopen("input.txt", "r", stdin);
#else
ios_base::sync_with_stdio(0); cin.tie(0);
#endif
int n, m;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
cin >> a[i][j];
}
}
int ans = 0;
for (int i = n - 1; i >= 0; --i) {
for (int j = m - 1; j >= 0; --j) {
row[i][j] = row[i][j + 1] + (a[i][j] == 'O');
col[i][j] = col[i + 1][j] + (a[i][j] == 'I');
if (a[i][j] == 'J') {
ans += row[i][j] * col[i][j];
}
}
}
cout << ans << '\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |