-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathB.cpp
79 lines (66 loc) · 1.66 KB
/
B.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 2e18
char grid[110][110];
ll cnt[110][110];
int main()
{
ll n, k2;
cin >> n >> k2;
for(ll i = 1; i <= n; i++)
scanf(" %s", grid[i] + 1);
for(ll i = 1; i <= n; i++) {
for(ll j = 1; j <= n; j++) {
//cout << grid[i][j] << " ";
if(grid[i][j] == '#')
continue;
bool test = 1;
for(ll k = j, m = 1; m <= k2; m++, k++) {
if(k > n) {
test = 0;
break;
}
if(grid[i][k] == '#') {
test = 0;
break;
}
}
if(test) {
for(ll k = j, m = 1; m <= k2; m++, k++) {
cnt[i][k]++;
}
}
test = 1;
for(ll k = i, m = 1; m <= k2; m++, k++) {
if(k > n) {
test = 0;
break;
}
if(grid[k][j] == '#') {
test = 0;
break;
}
}
if(test) {
for(ll k = i, m = 1; m <= k2; k++, m++) {
cnt[k][j]++;
}
}
}
//cout << endl;
}
ll row, col, mx = -1;
for(ll i = 1; i <= n; i++) {
for(ll j = 1; j <= n; j++) {
if(mx < cnt[i][j]) {
row = i;
col = j;
mx = cnt[i][j];
}
}
}
//cout << cnt[6][1] << endl;
cout << row << " " << col << endl;
return 0;
}