# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
485206 | chungdinh | Bitaro the Brave (JOI19_ho_t1) | C++17 | 262 ms | 91004 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 <cstdio>
#include <string>
#include <queue>
#include <iostream>
using namespace std;
#define endl "\n"
#define cntbit(x) __builtin_popcount(x)
#define on(b, x) (b & (1 << x))
#define all(x) x.begin(), x.end()
#define gcd __gcd
#define ll long long
#define ii pair<int, int>
const int N = 3e3 + 5;
const ll MOD = 998244353;
const int iINF = 1e9;
const ll INF = 1e18;
int n, m;
string g[N];
ii z[N][N];
int main() {
#ifdef CHUNGDINH
freopen("main.inp", "r", stdin);
#endif
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) cin >> g[i];
ll res = 0;
for (int i = n - 1; i >= 0; i--) {
for (int j = m - 1; j >= 0; j--) {
ii &a = z[i][j];
if (i == n - 1) a.first = 0;
else a.first = z[i + 1][j].first + (g[i + 1][j] == 'I');
if (j == m - 1) a.second = 0;
else a.second = z[i][j + 1].second + (g[i][j + 1] == 'O');
if (g[i][j] == 'J') res += (ll)a.first * a.second;
}
}
printf("%lld", res);
}
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... |