제출 #535084

#제출 시각아이디문제언어결과실행 시간메모리
535084amunduzbaevDango Maker (JOI18_dango_maker)C++17
13 / 100
1 ms232 KiB
#include "bits/stdc++.h" using namespace std; #define ar array signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n, m; cin>>n>>m; vector<string> a(n); for(int i=0;i<n;i++){ cin>>a[i]; } vector<vector<int>> is(n, vector<int>(m)); int res = 0; auto can = [&](int i, int j){ return (j+2 < m && !is[i][j] && !is[i][j+1] && !is[i][j+2] && a[i][j] == 'R' && a[i][j+1] == 'G' && a[i][j+2] == 'W'); }; auto mark = [&](int i, int j){ res++; is[i][j] = is[i][j+1] = is[i][j+2] = 1; }; auto can_ = [&](int i, int j){ return (i+2 < n && !is[i][j] && !is[i+1][j] && !is[i+2][j] && a[i][j] == 'R' && a[i+1][j] == 'G' && a[i+2][j] == 'W'); }; auto mark_ = [&](int i, int j){ res++; is[i][j] = is[i+1][j] = is[i+2][j] = 1; }; int ch[3][2] = { {0, 0}, {1, -1}, {2, -2} }; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(can(i, j)){ mark(i, j); continue; } auto check = [&](int x, int y){ return (0 <= x && x < n && 0 <= y && y < m); }; int c=0; for(int t=0;t<3;t++){ int x = i + ch[t][0], y = j + ch[t][1]; c += (check(x, y) && can(x, y)); } if(c <= 1 && can_(i, j)){ mark_(i, j); } } } cout<<res<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...