Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false); cin.tie(0);
- int n, m;
- cin >> n >> m;
- vector<string> a(n);
- for (int i = 0; i < n; i++) {
- cin >> a[i];
- }
- bool flag = true;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- if (a[i][j] == '#') continue;
- int degree = 0;
- if (i != 0 && a[i - 1][j] != '#') degree++;
- if (i != n - 1 && a[i + 1][j] != '#') degree++;
- if (j != 0 && a[i][j - 1] != '#') degree++;
- if (j != m - 1 && a[i][j + 1] != '#') degree++;
- if (degree >= 3) {
- cout << "YES\n";
- return 0;
- }
- if (degree == 1) flag = false;
- }
- }
- if (flag) cout << "YES\n";
- else cout << "NO\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement