# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
897218 | duckindog | Bitaro the Brave (JOI19_ho_t1) | C++14 | 120 ms | 80116 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.
// from duckindog wth depression
#include<bits/stdc++.h>
using namespace std;
const int N = 3e3 + 10;
int h, w;
char a[N][N];
int fi[N][N], fo[N][N];
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
if (fopen("duck.inp", "r")) {
freopen("duck.inp", "r", stdin);
freopen("duck.out", "w", stdout);
}
cin >> h >> w;
for (int i = 1; i <= h; ++i) {
string s; cin >> s;
for (int j = 1; j <= w; ++j) a[i][j] = s[j - 1];
}
for (int j = 1; j <= w; ++j)
for (int i = 1; i <= h; ++i) fi[i][j] = fi[i - 1][j] + (a[i][j] == 'I');
for (int i = 1; i <= h; ++i)
for (int j = 1; j <= w; ++j) fo[i][j] = fo[i][j - 1] + (a[i][j] == 'O');
long long answer = 0;
for (int i = 1; i <= h; ++i) {
for (int j = 1; j <= w; ++j) {
if (a[i][j] != 'J') continue;
int O = fo[i][w] - fo[i][j - 1];
int I = fi[h][j] - fi[i - 1][j];
answer = answer + 1ll * O * I;
}
}
cout << answer;
}
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... |