Submission #1131531

#TimeUsernameProblemLanguageResultExecution timeMemory
1131531lopkusBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
330 ms150336 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; char a[n + 1][m + 1]; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { cin >> a[i][j]; } } int sufo[n + 2][m + 2]; int sufi[n + 2][m + 2]; for(int i = 0; i <= n + 1; i++) { for(int j = 0; j <= m + 1; j++) { sufo[i][j] = 0; sufi[i][j] = 0; } } for(int i = 1; i <= n; i++) { for(int j = m; j >= 1; j--) { sufo[i][j] = sufo[i][j + 1]; if(a[i][j] == 'O') { sufo[i][j] += 1; } } } for(int i = 1; i <= m; i++) { for(int j = n; j >= 1; j--) { sufi[j][i] = sufi[j + 1][i]; if(a[j][i] == 'I') { sufi[j][i] += 1; } } } int ans = 0; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { if(a[i][j] == 'J') { ans += sufo[i][j + 1] * sufi[i + 1][j]; } } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...