Submission #743177

#TimeUsernameProblemLanguageResultExecution timeMemory
743177josanneo22Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
466 ms159024 KiB
#include <bits/stdc++.h> #include<unordered_map> using namespace std; #define mp make_pair #define pb push_back #define pii pair<int,int> #define fi first #define se second #define int long long void solve() { int n,m; cin >> n >> m; vector<vector<int>> ingot(n, vector<int>(m)), orb(n, vector<int>(m)); vector<vector<char>> grid(n, vector<char>(m)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> grid[i][j]; if (grid[i][j] == 'I') ingot[i][j]++; if (grid[i][j] == 'O') orb[i][j]++; } } for (int j = 0;j < m; j++) { for(int i=n-2;i>=0;i--){ ingot[i][j] += ingot[i+1][j]; } } for (int i = 0; i < n; i++) { for (int j = m - 2; j >= 0; j--) { orb[i][j] += orb[i][j + 1]; } } int ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (grid[i][j] == 'J') { ans += ingot[i][j] * orb[i][j]; } } } cout << ans << '\n'; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...