Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
JOI 2017 Yo 3rd
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <cmath>
#include <cstring>
int n, m, d;
char arr[110][110];
int main() {
std::cin >> n >> m >> d;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j) {
char c;
std::cin >> c;
arr[i][j] = c;
}
}
int ans = 0;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j) {
bool flag = true;
for(int k = 0; k < d; ++k) {
if(arr[i][j + k] == '#' || j + k >= m) {
flag = false;
break;
}
}
if(flag)
++ans;
flag = true;
for(int k = 0; k < d; ++k) {
if(arr[i + k][j] == '#' || i + k >= n) {
flag = false;
break;
}
}
if(flag)
++ans;
}
}
std::cout << ans << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment