Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PB push_back
#define PPB pop_back
#define MK make_pair
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;
typedef pair<int, pii> pipii;
constexpr int INF = 1LL << 61;
//constexpr int MOD = 1000000007;
//constexpr int MAX_N = 55;
int h, w, d, field[105][105];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> h >> w >> d;
for (int y = 0; y < h; ++y) {
string s;
cin >> s;
for (int x = 0; x < w; ++x) {
field[x][y] = (s[x] == '#');
}
}
int ans = 0;
for (int y = 0; y < h; ++y) {
for (int x = 0; x <= w - d; ++x) {
bool flg = true;
for (int i = 0; i < d; ++i) {
if (field[x + i][y]) {
flg = false;
break;
}
}
if (!flg) continue;
ans++;
}
}
for (int x = 0; x < w; ++x) {
for (int y = 0; y <= h - d; ++y) {
bool flg = true;
for (int i = 0; i < d; ++i) {
if (field[x][y + i]) {
flg = false;
break;
}
}
if (!flg) continue;
ans++;
}
}
cout << ans << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment