# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1023572 | vjudge1 | Bitaro the Brave (JOI19_ho_t1) | C++17 | 202 ms | 79704 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>
#define ll long long
#define ld long double
#define eb emplace_back
#define task ""
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define nx freopen (task".inp","r",stdin), freopen (task".out","w",stdout);
#define fi first
#define se second
#define pii pair <int, int>
#define tii tuple <int, int, int>
#define all(s) s.begin(), s.end()
using namespace std;
const int nmax = 3e3 + 2;
int h, w;
char s[nmax][nmax];
int cntO[nmax][nmax], cntI[nmax][nmax];
int main()
{
if (ifstream(task".inp")) nx
fast
cin >> h >> w;
for (int i = 1; i <= h; ++i)
for (int j = 1; j <= w; ++j)
cin >> s[i][j];
for (int i = 1; i <= h; ++i)
for (int j = w; j >= 1; --j)
cntO[i][j] = cntO[i][j + 1] + (s[i][j] == 'O');
for (int j = 1; j <= w; ++j)
for (int i = h; i >= 1; --i)
cntI[j][i] = cntI[j][i + 1] + (s[i][j] == 'I');
ll ans = 0;
for (int i = 1; i <= h; ++i)
for (int j = 1; j <= w; ++j)
if (s[i][j] == 'J')
ans += cntO[i][j] * cntI[j][i];
cout << 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... |