Submission #418248

#TimeUsernameProblemLanguageResultExecution timeMemory
418248jasminBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
303 ms151748 KiB
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int h, w; cin >> h >> w; vector<string> stones(h); for(int i=0; i<h; i++){ cin >> stones[i]; } vector<vector<int> > orbs(h, vector<int> (w, 0)); vector<vector<int> > ingos(h, vector<int> (w, 0)); for(int i=0; i<h; i++){ if(stones[i][w-1]=='O'){ orbs[i][w-1]=1; } for(int j=w-2; j>=0; j--){ orbs[i][j]=orbs[i][j+1]+(stones[i][j]=='O'? 1: 0); } } for(int j=0; j<w; j++){ if(stones[h-1][j]=='I'){ ingos[h-1][j]=1; } for(int i=h-2; i>=0; i--){ ingos[i][j]=ingos[i+1][j]+(stones[i][j]=='I'? 1: 0); } } int ans=0; for(int i=0; i<h; i++){ for(int j=0; j<w; j++){ if(stones[i][j]=='J'){ ans+=orbs[i][j]*ingos[i][j]; } } } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...