This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> grid (n,vector<int>(m));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
char c;
cin >> c;
if (c == '#') grid[i][j] = 1;
}
}
int ans = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
if (grid[i][j]) {
int to = i;
for (int k = i+1; k < n; ++k) {
if (grid[k][j]) {
to = k;
break;
}
}
if (to-i<2)continue;
bool ok = true;
for (int k = 1; k <= (to-i)/2; ++k) {
//cout << j-k << ' ' << j+k << '\n';
if (j-k < 0 || j + k >= m) ok = false;
if (!grid[i+k][j-k] || !grid[i+k][j+k]) ok = false;
for (int t = j-k+1; t <= j+k-1 ; ++t) {
if (grid[i+k][t]) {
ok = false;
break;
}
}
if (!ok) break;
}
//if (ok) cout << "f ";
for (int k = (to-i)/2+1; k < to-i; ++k) {
int dif = (to - i)-k;
if (j-dif < 0 || j + dif >= m) ok = false;
if (!grid[i+k][j-dif] || !grid[i+k][j+dif]) ok = false;
for (int t = j-dif+1; t <= j+dif-1 ; ++t) {
if (grid[i+k][t]) {
ok = false;
break;
}
}
//cout << j-dif << ' ' << j+dif << '\n';
if (!ok) break;
}
if (ok) ++ans;
}
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |