Submission #1167171

#TimeUsernameProblemLanguageResultExecution timeMemory
1167171InvMODBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
300 ms106588 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m; cin >> n >> m; vector<vector<int>> J(n + 1, vector<int>(m + 1)); vector<vector<int>> O(n + 1, vector<int>(m + 1)); vector<vector<int>> I(n + 1, vector<int>(m + 1)); for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ char c; cin >> c; if(c == 'J') J[i][j] = 1; if(c == 'O') O[i][j] = 1; if(c == 'I') I[i][j] = 1; } } for(int i = n - 1; i >= 1; i--){ for(int j = 1; j <= m; j++){ I[i][j] = I[i + 1][j] + I[i][j]; } } for(int i = m - 1; i >= 1; i--){ for(int j = 1; j <= n; j++){ O[j][i] = O[j][i] + O[j][i + 1]; } } ll answer = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(J[i][j]){ answer = answer + 1ll * O[i][j] * I[i][j]; } } } cout << answer << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...