Submission #742795

#TimeUsernameProblemLanguageResultExecution timeMemory
742795haydendooBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
158 ms17920 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h,w;
    cin >> h >> w;
    char a[h][w];
    for(int i=0; i<h; ++i) {
        for(int j=0; j<w; ++j) cin >> a[i][j];
    }
    int ans=0;
    int cnt[w]; memset(cnt,0,sizeof(cnt));
    for(int i=h-1; i>=0; --i) {
        int curr=0;
        for(int j=w-1; j>=0; --j) {
            if(a[i][j]=='O') ++curr;
            else if(a[i][j]=='I') {
                ++cnt[j];
            }
            else ans+=cnt[j]*curr;
        }
    }
    cout << ans;
}
/*
6 
4 1 
1 5
10 3
9 1
4 2
5 3
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...