# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127605 | IOrtroiii | Bitaro the Brave (JOI19_ho_t1) | C++14 | 332 ms | 88904 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;
const int N = 3030;
char a[N][N];
int row[N][N];
int col[N][N];
int main() {
int n, m;
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; ++i) {
scanf("%s", a[i] + 1);
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (a[i][j] == 'O') {
++row[i][j];
} else if (a[i][j] == 'I') {
++col[i][j];
}
}
}
for (int i = 1; i <= n; ++i) {
for (int j = m; j > 0; --j) {
row[i][j] += row[i][j + 1];
}
}
for (int j = 1; j <= m; ++j) {
for (int i = n; i > 0; --i) {
col[i][j] += col[i + 1][j];
}
}
long long ans = 0;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (a[i][j] == 'J') {
ans += row[i][j] * col[i][j];
}
}
}
printf("%lld\n", ans);
}
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... |