Submission #995002

#TimeUsernameProblemLanguageResultExecution timeMemory
995002SuPythonyBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
268 ms88816 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int h,w; cin>>h>>w; vector<string> a; for (int i=0; i<h; i++) { string s; cin>>s; a.push_back(s); } vector<vector<int>> osf(h,vector<int>(w,0)); for (int i=0; i<h; i++) { if (a[i][w-1]=='O') osf[i][w-1]=1; for (int j=w-2; j>=0; j--) { if (a[i][j]=='O') osf[i][j]=osf[i][j+1]+1; else osf[i][j]=osf[i][j+1]; } } vector<vector<int>> isf(h,vector<int>(w,0)); for (int j=0; j<w; j++) { if (a[h-1][j]=='I') isf[h-1][j]=1; for (int i=h-2; i>=0; i--) { if (a[i][j]=='I') isf[i][j]=isf[i+1][j]+1; else isf[i][j]=isf[i+1][j]; } } ll ans=0; for (int i=0; i<h; i++) { for (int j=0; j<w; j++) { if (a[i][j]=='J') { ans+=osf[i][j]*isf[i][j]; } } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...