제출 #582877

#제출 시각아이디문제언어결과실행 시간메모리
5828771neBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
212 ms89632 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n,m;cin>>n>>m; vector<string>arr(n); for (int i = 0;i<n;++i)cin>>arr[i]; long long ans = 0; vector<vector<int>>pref(n,vector<int>(m + 1,0)); vector<vector<int>>pref2(m,vector<int>(n + 1,0)); for (int i = 0;i<n;++i){ for (int j = 0;j<m;++j){ pref[i][j + 1] = pref[i][j] + (arr[i][j] == 'O'); } } for (int i = 0;i<m;++i){ for (int j = 0;j<n;++j){ pref2[i][j + 1] = pref2[i][j] + (arr[j][i] == 'I'); } } for (int i = 0;i<n;++i){ for (int j = 0;j<m;++j){ if (arr[i][j]!='J')continue; int l = pref[i][m] - pref[i][j]; int k = pref2[j][n] - pref2[j][i]; ans+=l * k; } } cout<<ans<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...