Submission #915328

#TimeUsernameProblemLanguageResultExecution timeMemory
915328ace5Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
223 ms115352 KiB
#include <bits/stdc++.h> using namespace std; vector<vector<int>> a; vector<vector<int>> r; vector<vector<int>> b; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int h,w; cin >> h >> w; a.resize(h); for(int i =0;i < h;++i) { a[i].resize(w); for(int j = 0;j < w;++j) { char x; cin >> x; a[i][j] = (x == 'J' ? 0 : (x == 'O' ? 1 : 2)); } } r.resize(h); for(int i = 0;i < h;++i) { r[i].resize(w); for(int j = w-1;j >= 0;--j) { r[i][j] = (j == w-1 ? 0 : r[i][j+1] + (a[i][j+1] == 1)); } } b.resize(h); for(int i = h-1;i >= 0;--i) { b[i].resize(w); for(int j = 0;j < w;++j) { b[i][j] = (i == h-1 ? 0 : b[i+1][j] + (a[i+1][j] == 2)); } } int64_t ans = 0; for(int i = 0;i < h;++i) { for(int j = 0;j < w;++j) { ans += (a[i][j] == 0)*(r[i][j]*b[i][j]); } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...