Submission #717560

#TimeUsernameProblemLanguageResultExecution timeMemory
717560vjudge1Bitaro the Brave (JOI19_ho_t1)C++17
50 / 100
1073 ms55260 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

vector<pii> posJ;
vector<int> posO[3010], posI[3010];
int n, m;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            char c; cin >> c;
            if(c == 'J') {
                posJ.push_back({i, j});
            }
            else if(c == 'O') {
                posO[i].push_back(j);
            }
            else {
                posI[j].push_back(i);
            }
        }
    }
    ll res = 0;
    for(auto [i, j] : posJ) {
        ll cntO = 0, cntI = 0;
        for(auto l : posO[i]) {
            if(l > j) cntO++;
        }
        for(auto k : posI[j]) {
            if(k > i) cntI++;
        }
        res += (cntO * cntI);
    }
    cout << res << '\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...