제출 #1258773

#제출 시각아이디문제언어결과실행 시간메모리
1258773vincent_nthBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
95 ms79708 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int m, n, pi[3002][3002], po[3002]; char a[3002][3002]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> m >> n; for(int i = 1; i <= m; i++) { string s; cin >> s; s = "#" + s; for(int j = 1; j <= n; j++) { a[i][j] = s[j]; } } for(int i = m; i >= 1; i--) { for(int j = 1; j <= n; j++) { pi[i][j] = pi[i + 1][j] + (a[i][j] == 'I'); } } int ans = 0; for(int i = 1; i <= m; i++) { po[n + 1] = 0; for(int j = n; j >= 1; j--) { po[j] = po[j + 1] + (a[i][j] == 'O'); } for(int j = 1; j <= n; j++) { if(a[i][j] == 'J') { ans += po[j + 1] * pi[i + 1][j]; } } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...