Submission #339474

#TimeUsernameProblemLanguageResultExecution timeMemory
339474bigDuckBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
199 ms9324 KiB
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount


char a[3010][3010];
short int n, m;
short int ing[3010], orb[3010];



int32_t main(){
INIT
cin>>n>>m;
for(int i=1; i<=n; i++){
    for(int j=1; j<=m; j++){
        cin>>a[i][j];
    }
}

ll res=0;
for(int i=n; i>=1; i--){
    for(int j=m; j>=1; j--){
       if(a[i][j]>='J'){
        if(a[i][j]=='J'){
            res+=orb[i]*ing[j];
        }
        else{
            orb[i]++;
        }
       }
       else{
        ing[j]++;
       }
    }
}
cout<<res;



return 0;
}



#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...