Submission #108546

#TimeUsernameProblemLanguageResultExecution timeMemory
108546DiuvenBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
328 ms88824 KiB
#include <iostream> using namespace std; int h, w; char S[3010][3010]; int O[3010][3010], I[3010][3010]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cin>>h>>w; for(int i=0; i<h; i++) cin>>S[i]; for(int i=0; i<h; i++) for(int j=w-1; j>=0; j--) O[i][j] = O[i][j+1] + (S[i][j]=='O'); for(int j=0; j<w; j++) for(int i=h-1; i>=0; i--) I[i][j] = I[i+1][j] + (S[i][j]=='I'); long long ans = 0; for(int i=0; i<h; i++) for(int j=0; j<w; j++) ans += 1LL*(S[i][j]=='J') * O[i][j] * I[i][j]; cout<<ans<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...