제출 #574052

#제출 시각아이디문제언어결과실행 시간메모리
574052Ronin13Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
723 ms88304 KiB
#include<bits/stdc++.h> #define ll long long #define ull unsigned ll #define f first #define s second #define pll pair<ll,ll> #define pii pair<int,int> #define pb push_back #define epb emplace_back using namespace std; int prefr[3001][3001], prefc[3001][3001]; int main(){ int n, m; cin >> n >> m; char c[n + 1][m + 1]; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++) cin >> c[i][j]; } for(int i = 1; i <= n; i++){ prefr[i][0] = 0; for(int j = 1; j <= m; j++) { prefr[i][j] = prefr[i][j - 1]; if(c[i][j] == 'O') prefr[i][j]++; } } for(int j = 1; j <= m; j++){ prefc[0][j] = 0; for(int i = 1; i <= n; i++){ prefc[i][j] = prefc[i - 1][j]; if(c[i][j] == 'I') prefc[i][j]++; } } ll ans = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(c[i][j] == 'J'){ ll x = prefr[i][m] - prefr[i][j]; ll y = prefc[n][j] - prefc[i][j]; ans += x * y; } } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...