# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1023635 | vjudge1 | Bitaro the Brave (JOI19_ho_t1) | C++17 | 171 ms | 88560 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 ll long long
#define pb push_back
const int N = 3005;
int n, m;
char a[N][N];
ll c[N][N];
void sol() {
cin >> n >> m;
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= m; ++j)
cin >> a[i][j];
ll ans = 0;
for (int i = 1; i <= n; ++i) {
ll cntO = 0;
for (int j = m; j >= 1; --j) {
if (a[i][j] == 'O') cntO++, c[i][j] = c[i-1][j];
else if (a[i][j] == 'J') c[i][j] = c[i-1][j] + cntO;
else ans += c[i-1][j], c[i][j] = c[i-1][j];
}
}
cout << ans;
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
if (fopen("A.inp", "r")) freopen("A.inp", "r", stdin);
int tc = 1; // cin >> tc;
for (int test = 1; test <= tc; ++test) sol();
}
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... |