-
-
Save yurahuna/84057a1e6c33769cd045b354a66bc60e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; | |
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1}; | |
int H, W; | |
vector<string> s; | |
bool inside(int x, int y) { | |
return 0 <= x && x < H && 0 <= y && y < W; | |
} | |
bool valid(int i, int j) { | |
if (i == 0) return false; | |
if (s[i][j] != '-') return false;; | |
rep(k, 8) { | |
int ni = i + dx[k], nj = j + dy[k]; | |
if (!inside(ni, nj)) continue; | |
if (s[ni][nj] == 'x') return false; | |
if ((k == 1 || k == 3) && s[ni][nj] == 'o') return false; | |
} | |
return true; | |
} | |
signed main() { | |
std::ios::sync_with_stdio(false); | |
std::cin.tie(0); | |
cin >> H >> W; | |
s.resize(H); | |
rep(i, H) cin >> s[i]; | |
int ans = 0; | |
rep(i, H) { | |
rep(j, W) { | |
ans += valid(i, j); | |
} | |
} | |
cout << ans << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment