Submission #1179708

#TimeUsernameProblemLanguageResultExecution timeMemory
1179708anteknneBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
141 ms80740 KiB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define st first
#define nd second
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define debug false

const int MAXN = 3000;
int spref1[MAXN + 1][MAXN + 1];
int spref2[MAXN + 1][MAXN + 1];
string a[MAXN];

int main () {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int h, w;
    cin >> h >> w;

    for (int i = 0; i < h; i ++) {
        cin >> a[i];
    }

    for (int i = 0; i < h; i ++) {
        for (int j = w - 1; j >= 0; j --) {
            spref1[i][j] = spref1[i][j + 1] + (a[i][j] == 'O');
        }
    }

    for (int i = 0; i < w; i ++) {
        for (int j = h - 1; j >= 0; j --) {
            spref2[i][j] = spref2[i][j + 1] + (a[j][i] == 'I');
        }
    }

    ll wyn = 0;
    for (int i = 0; i < h; i ++) {
        for (int j = 0; j < w; j ++) {
            if (a[i][j] != 'J') {
                continue;
            }
            wyn += ll(spref1[i][j] * spref2[j][i]);
        }
    }
    cout << wyn << "\n";

    return 0;
}


#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...