Submission #217142

#TimeUsernameProblemLanguageResultExecution timeMemory
217142kshitij_sodaniBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
628 ms220536 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; typedef long long int llo; #define mp make_pair #define pb push_back #define a first #define b second #define endl "\n" llo mod=1000000007; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); //setIO(""); llo n,m; cin>>n>>m; char ss; llo it[n][m]; for(llo i=0;i<n;i++){ for(llo j=0;j<m;j++){ cin>>ss; if(ss=='J'){ it[i][j]=0; } else if(ss=='O'){ it[i][j]=1; } else{ it[i][j]=2; } } } llo pre[n][m]; for(llo i=0;i<n;i++){ for(llo j=m-1;j>=0;j--){ llo cc=0; if(it[i][j]==1){ cc=1; } pre[i][j]=cc; if(j<m-1){ pre[i][j]+=pre[i][j+1]; } } } llo pre2[n][m]; for(llo j=0;j<m;j++){ for(llo i=n-1;i>=0;i--){ llo cc=0; if(it[i][j]==2){ cc=1; } pre2[i][j]=cc; if(i<n-1){ pre2[i][j]+=pre2[i+1][j]; } } } llo tot=0; for(llo i=0;i<n;i++){ for(llo j=0;j<m;j++){ if(it[i][j]==0){ tot+=pre[i][j]*pre2[i][j]; } } } cout<<tot<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...