제출 #1320325

#제출 시각아이디문제언어결과실행 시간메모리
1320325Kel_MahmutBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
322 ms82508 KiB
#include <bits/stdc++.h> #define pb push_back #define endl ("\n") #define all(aa) aa.begin(), aa.end() typedef long long ll; using namespace std; int main(){ int n, m; cin >> n >> m; vector<string> a(n); for(int i = 0; i < n; i++) cin >> a[i]; vector<vector<int>> suf(n, vector<int> (m + 1)); vector<vector<int>> asa(n, vector<int> (m + 1)); for(int i = 0; i < n; i++){ for(int j = m - 2; j >= 0; j--){ suf[i][j] = suf[i][j + 1] + (a[i][j + 1] == 'O'); } } for(int j = 0; j < m; j++){ for(int i = n - 2; i >= 0; i--){ asa[i][j] = asa[i + 1][j] + (a[i + 1][j] == 'I'); } } ll ans = 0; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ if(a[i][j] == 'J'){ ans += suf[i][j] * asa[i][j]; } } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...