Submission #882440

#TimeUsernameProblemLanguageResultExecution timeMemory
882440hennesseyBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
524 ms220924 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { //your code goes here int n, m; cin >> n >> m; vector <vector <int>> arr(n, vector <int>(m)); vector <vector <int>> pref(n, vector <int>(m)); vector <vector <int>> pref2(n, vector <int>(m)); for(int i = 0; i < n; i++) { string s; cin >> s; for(int j = 0; j < m; j++) { if(s[j] == 'J') { arr[i][j] = 1; } else if(s[j] == 'O') { arr[i][j] = 2; } else { arr[i][j] = 3; } } } for(int i = 0; i < n; i++) { for(int j = m-1; j >= 0; j--) { if(arr[i][j] == 2) { pref[i][j] += 1; } if(j == m-1) { continue; } pref[i][j] += pref[i][j+1]; } } for(int i = 0; i < m; i++) { for(int j = n-1; j >= 0; j--) { if(arr[j][i] == 3) { pref2[j][i] += 1; } if(j == n-1) { continue; } pref2[j][i] += pref2[j+1][i]; } } int total = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(arr[i][j] == 1) { int val1 = pref[i][j]; int val2 = pref2[i][j]; // cout << val1 << " " << val2 << " " << i << " " << j << endl; total += (val1*val2); } } } cout << total << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...