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>
typedef long long ll;
int main() {
std::ios::sync_with_stdio(0);
int h, w; std::cin >> h >> w;
std::vector <std::string> g(h);
std::vector <std::vector <ll>> a(4269, std::vector <ll> (4269, 0)), b(a);
for (auto& x : g) std::cin >> x;
for (int i = 0; i < w; i++)
for (int j = h - 1; j >= 0; j--)
b[i][j] = (j != h - 1 ? b[i][j + 1] : 0) + (g[j][i] == 'I');
for (int i = 0; i < h; i++)
for (int j = w - 1; j >= 0; j--)
a[i][j] = (j != w - 1 ? a[i][j + 1] : 0) + (g[i][j] == 'O');
ll ans = 0;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
ans += (g[i][j] == 'J') * a[i][j] * b[j][i];
std::cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |