# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
531022 | buidangnguyen05 | Bitaro the Brave (JOI19_ho_t1) | C++14 | 347 ms | 118500 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.
/* input
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e3 + 10;
int d[N][N], r[N][N];
char s[N][N];
signed main() {
cin.tie(0)->sync_with_stdio(0);
if (fopen("task.inp", "r")) {
freopen("task.inp", "r", stdin);
freopen("task.out", "w", stdout);
}
int m, n; cin >> m >> n;
for (int i = 1; i <= m; ++i) for (int j = 1; j <= n; ++j) cin >> s[i][j];
for (int i = 1; i <= m; ++i) for (int j = n; j; --j) r[i][j] = r[i][j + 1] + (s[i][j + 1] == 'O');
for (int j = 1; j <= n; ++j) for (int i = m; i; --i) d[i][j] = d[i + 1][j] + (s[i + 1][j] == 'I');
ll res = 0;
for (int i = 1; i <= m; ++i) for (int j = 1; j <= n; ++j) if (s[i][j] == 'J') res += r[i][j] * d[i][j];
cout << res << "\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... |