-
Notifications
You must be signed in to change notification settings - Fork 1
/
C.cpp
61 lines (51 loc) · 1.35 KB
/
C.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <bits/stdc++.h>
using namespace std;
#define ll long long
char graph[2009][2009];
bool visit[2009][2009];
bool visit2[2009][2009];
int n, m, p;
ll ans = 0;
int main()
{
cin >> n >> m >> p;
for(int i = 0; i < n; i++) {
scanf("%s", graph[i]);
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
if(graph[i][j] == '.') {
int cnt = 0, k;
if(visit[i][j] == 0) {
for(k = j; k < m; k++) {
if(graph[i][k] == '*')
break;
visit[i][k] = 1;
cnt++;
if(cnt == p) {
ans++;
cnt--;
}
}
}
if(visit2[i][j] == 0) {
cnt = 0;
for(k = i; k < n; k++) {
if(graph[k][j] == '*')
break;
visit2[k][j] = 1;
cnt++;
if(cnt == p) {
ans++;
cnt--;
}
}
}
}
}
}
if(p == 1)
ans = ans / 2;
cout << ans << endl;
return 0;
}