Submission #891305

#TimeUsernameProblemLanguageResultExecution timeMemory
891305IrateBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
172 ms88912 KiB
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector<vector<char>>grid(n + 1, vector<char>(m + 1)); for(int i = 1;i <= n;++i){ for(int j = 1;j <= m;++j){ cin >> grid[i][j]; } } vector<vector<int>>orbs(n + 1, vector<int>(m + 1)); for(int i = 1;i <= n;++i){ for(int j = m;j >= 1;--j){ if(j + 1 <= m)orbs[i][j] = orbs[i][j + 1] + (grid[i][j] == 'O'); else orbs[i][j] = (grid[i][j] == 'O'); } } vector<vector<int>>ingots(n + 1, vector<int>(m + 1)); for(int i = n;i >= 1;--i){ for(int j = 1;j <= m;++j){ if(i + 1 <= n)ingots[i][j] = ingots[i + 1][j] + (grid[i][j] == 'I'); else ingots[i][j] = (grid[i][j] == 'I'); } } long long res = 0; for(int i = 1;i <= n;++i){ for(int j = 1;j <= m;++j){ if(grid[i][j] == 'J'){ res += ingots[i][j] * orbs[i][j]; } } } cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...