Submission #1264993

#TimeUsernameProblemLanguageResultExecution timeMemory
1264993avohadoBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
112 ms9252 KiB
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define maxn 200005
#define f first
#define s second
#define ll long long
#define pb(x) push_back(x)
#define all(v) v.begin(), v.end()
void solve(){
    int w, h;
    cin >> h >> w;
    char c[h][w];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> c[i][j];
        }
    }
    int f[w]{};
    long long sum=0;
    for(int i=0; i<h; i++){
        int sh=0;
        for(int j=w-1; j>=0; j--){
            if(c[i][j]=='O'){
                sh++;
            }else if(c[i][j]=='J'){
                f[j]+=sh;
            }else{
                sum+=f[j];
            }
        }
    }
    cout << sum;
}
int main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    int t=1;
    //cin >> t;
    while(t--){
        solve();
        cout << "\n";
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...