-
-
Save fredbr/453dac9fef526f578b4978dd39d65fbc 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
//solucao de Frederico Bulhoes | |
#include <bits/stdc++.h> | |
using namespace std; | |
const int maxn = 1010; | |
char v[maxn][maxn]; | |
int main() | |
{ | |
int m, n; | |
cin >> m >> n; | |
for (int i = 0; i <= m+1; i++) { | |
v[i][0] = '.'; | |
v[i][n+1] = '.'; | |
} | |
for (int i = 0; i <= n+1; i++) { | |
v[0][i] = '.'; | |
v[m+1][i] = '.'; | |
} | |
for (int i = 1; i <= m; i++) { | |
for (int j = 1; j <= n; j++) { | |
cin >> v[i][j]; | |
} | |
} | |
int total = 0; | |
for (int i = 1; i <= m; i++) { | |
for (int j = 1; j <= n; j++) { | |
if (v[i][j] == '#') { | |
if (v[i-1][j] == '.' or v[i+1][j] == '.' or v[i][j-1] == '.' or v[i][j+1] == '.') total++; | |
} | |
} | |
} | |
cout << total << "\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment