Submission #1127790

#TimeUsernameProblemLanguageResultExecution timeMemory
1127790tsengangBitaro the Brave (JOI19_ho_t1)C++20
50 / 100
1099 ms91520 KiB
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define vodka void
#define ertunt return
using namespace std;
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    vector<vector<ll>> J(h + 5), O(h + 5), I(w + 5);
    for (ll i = 0; i < h; i++) {
        cin >> s[i];
        for (ll j = 0; j < w; j++) {
            if (s[i][j] == 'O') O[i].pb(j);
        }
    }
    for (ll i = 0; i < w; i++) {
        for (ll j = 0; j < h; j++) {
            if (s[j][i] == 'I') I[i].pb(j);
        }
    }
    ll ans = 0;
    for (ll i = 0; i < h; i++) {
        for (ll j = 0; j < w; j++) {
            if (s[i][j] == 'J') {
                ans+=I[j].size()*O[i].size();
            }
            if (s[i][j] == 'O') O[i].erase(find(all(O[i]), j));
            if (s[i][j] == 'I') I[j].erase(find(all(I[j]), i));
        }
    }
    cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...