Submission #1352193

#TimeUsernameProblemLanguageResultExecution timeMemory
1352193waygonzBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
423 ms91036 KiB
#include <bits/stdc++.h>
#define int long long
#define float long double
#define pii pair<int, int>
#define tii tuple<int, int, int>
#define f first
#define s second
#define ve vector
#define emb emplace_back
#define em emplace

using namespace std;

const int inf = 1e18;
const int mod = 1e9 + 7;

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h, w;
    cin >> h >> w;
    ve<string> a(h);
    for (auto &e : a) cin >> e;
    ve<ve<int>> x(h), y(w);
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            if (a[i][j] == 'O') x[i].emb(j);
    for (int i = 0; i < w; i++)
        for (int j = 0; j < h; j++)
            if (a[j][i] == 'I') y[i].emb(j);
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] != 'J') continue;
            int xc = x[i].end() - lower_bound(x[i].begin(), x[i].end(), j);
            int yc = y[j].end() - lower_bound(y[j].begin(), y[j].end(), i);
            ans += xc * yc;
        }
    }
    cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...