Submission #855762

#TimeUsernameProblemLanguageResultExecution timeMemory
855762annabeth9680Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
163 ms160940 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int MAXN = 3010; string grid[MAXN]; int cntI[MAXN][MAXN], cntO[MAXN][MAXN]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int H,W; cin >> H >> W; for(int i = 0;i<H;++i){ cin >> grid[i]; } for(int i = 0;i<H;++i){ int os = 0; for(int j = W-1;j>=0;--j){ if(grid[i][j] == 'J'){ cntO[i][j] = os; //cout << i << " " << j << " " << cntO[i][j] << "\n"; } else if(grid[i][j] == 'O') os++; } } for(int i = 0;i<W;++i){ int is = 0; for(int j = H-1;j>=0;--j){ if(grid[j][i] == 'J'){ cntI[j][i] = is; //cout << j << " " << i << " " << cntI[j][i] << "\n"; } else if(grid[j][i] == 'I') is++; } } int ans = 0; for(int i = 0;i<H;++i){ for(int j = 0;j<W;++j){ if(grid[i][j] == 'J'){ //cout << i << " " << j << " " << cntI[j][i] << " " << cntO[i][j] << "\n"; ans += cntI[i][j]*cntO[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...