Submission #382828

#TimeUsernameProblemLanguageResultExecution timeMemory
382828ritul_kr_singhBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
383 ms153452 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define sp << " " << #define nl << "\n" signed main(){ cin.tie(0)->sync_with_stdio(0); int h, w; cin >> h >> w; char g[h][w]; int orbs[h][w], ingots[h][w]; for(int i=0; i<h; ++i) for(int j=0; j<w; ++j) orbs[i][j] = ingots[i][j] = 0; for(int i=0; i<h; ++i){ for(int j=0; j<w; ++j){ cin >> g[i][j]; if(g[i][j]=='O') ++orbs[i][j]; if(g[i][j]=='I') ++ingots[i][j]; } } for(int i=h-2; i>=0; --i){ for(int j=w-2; j>=0; --j){ orbs[i][j] += orbs[i][j+1]; ingots[i][j] += ingots[i+1][j]; } } int ans = 0; for(int i=0; i<h; ++i){ for(int j=0; j<w; ++j){ if(g[i][j]=='J') ans += (orbs[i][j]*ingots[i][j]); } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...