Submission #1359253

#TimeUsernameProblemLanguageResultExecution timeMemory
1359253nnargizBitaro the Brave (JOI19_ho_t1)C++20
50 / 100
1096 ms9540 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
const int mod = 1e9+7;
const int inf = 1e18;
const int maxx = 1e6 + 5;
const int lg = 26;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solve() {
    int a, b, ans = 0;
    cin >> a >> b;
    vector <string> s(a);
    for (int i = 0; i < a; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < a; i++) {
        vector <int> pre(b + 1, 0);
        for (int j = b - 1; j >= 0; j--) {
            pre[j] = pre[j + 1];
            if (s[i][j] == 'O'){
                pre[j]++;
            }
        }
        for (int k = i + 1; k < a; k++) {
            for (int j = 0; j < b; j++) {
                if (s[i][j] == 'J' && s[k][j] == 'I') {
                    ans += pre[j + 1];
                }
            }
        }
    }
    cout << ans << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...