Submission #422452

#TimeUsernameProblemLanguageResultExecution timeMemory
422452snasibov05Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
495 ms161776 KiB
#include <iostream> #include <vector> using namespace std; #define int long long signed main() { int h, w; cin >> h >> w; vector<string> grid(h); for (int i = 0; i < h; ++i) { cin >> grid[i]; } vector<vector<int>> row_o(h, vector<int>(w)), col_i(w, vector<int>(h)); for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { if (grid[i][j] == 'O') row_o[i][j]++; if (grid[i][j] == 'I') col_i[j][i]++; } } for (int i = 0; i < h; ++i) { for (int j = w-2; j >= 0; --j) { row_o[i][j] += row_o[i][j+1]; } } for (int j = 0; j < w; ++j) { for (int i = h-2; i >= 0; --i){ col_i[j][i] += col_i[j][i+1]; } } int ans = 0; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { if (grid[i][j] == 'J') ans += row_o[i][j] * col_i[j][i]; } } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...