Submission #1122647

#TimeUsernameProblemLanguageResultExecution timeMemory
1122647AtabayRajabliBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
309 ms151400 KiB
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define int long long using namespace std; const int sz = 3e3 + 5; int n, m, orb[sz][sz], ing[sz][sz]; string s[sz]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i = 0; i < n; i++) { cin >> s[i]; for(int j = 0; j < m; j++) { if(s[i][j] == 'O') orb[i][j] = 1; if(s[i][j] == 'I') ing[i][j] = 1; } } for(int i = 0; i < n; i++) { for(int j = m - 1; j >= 0; j--) { orb[i][j] += orb[i][j + 1]; } } for(int i = 0; i < m; i++) { for(int j = n - 1; j >= 0; j--) { ing[j][i] += ing[j + 1][i]; } } int ans = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(s[i][j] == 'J') ans += orb[i][j + 1] * ing[i + 1][j]; } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...