Submission #1026286

#TimeUsernameProblemLanguageResultExecution timeMemory
1026286overwatch9Bitaro the Brave (JOI19_ho_t1)C++17
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n, m; cin >> n >> m; vector <string> grid(n+1); for (int i = 1; i <= n; i++) { cin >> grid[i]; grid[i] = "0" + grid[i]; } map <char, vector <vector <int>>> pfx; pfx['O'] = pfx['I'] = vector <vector <int>> (n+1, vector <int> (m+1)); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (grid[i][j] != 'J') pfx[grid[i][j]][i][j]++; pfx['O'][i][j] += pfx['O'][i][j-1]; pfx['I'][i][j] += pfx['I'][i-1][j]; } } ll ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (grid[i][j] != 'J') continue; ll a = pfx['O'][i][n] - pfx['O'][i][j]; ll b = pfx['I'][n][j] - pfx['I'][i][j]; ans += a * b; } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...