Submission #915326

#TimeUsernameProblemLanguageResultExecution timeMemory
915326ace5Bitaro the Brave (JOI19_ho_t1)C++17
50 / 100
277 ms274432 KiB
#include <bits/stdc++.h> using namespace std; #define int int64_t vector<vector<int>> a; vector<vector<int>> r[3]; vector<vector<int>> b[3]; signed 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)); } } for(int x = 0;x < 3;++x) { r[x].resize(h); for(int i = 0;i < h;++i) { r[x][i].resize(w); for(int j = w-1;j >= 0;--j) { r[x][i][j] = (j == w-1 ? 0 : r[x][i][j+1] + (a[i][j+1] == x)); } } } for(int x = 0;x < 3;++x) { b[x].resize(h); for(int i = h-1;i >= 0;--i) { b[x][i].resize(w); for(int j = 0;j < w;++j) { b[x][i][j] = (i == h-1 ? 0 : b[x][i+1][j] + (a[i+1][j] == x)); } } } int ans = 0; for(int i = 0;i < h;++i) { for(int j = 0;j < w;++j) { int f = (a[i][j]+1)%3; int s = (a[i][j]+2)%3; ans += (a[i][j] == 0)*(r[f][i][j]*b[s][i][j]); } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...