-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodeforces - 1028A - FindSquare.cpp
75 lines (64 loc) · 1.18 KB
/
codeforces - 1028A - FindSquare.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
#include<bits/stdc++.h>
using namespace std;
#define sz 120
typedef pair<int, int> mypair;
char table[sz][sz];
char ch;
int n, m;
int length, height;
mypair coordinate, initPos;
mypair getPositionOfB()
{
int x, y;
for(x=0; x<n; x++)
{
for(y=0; y<m; y++)
{
if(table[x][y]=='B')
{
return make_pair(x+1, y+1);
}
}
}
}
int getLength(mypair pos)
{
int i;
for(i=pos.second; i<m; i++)
{
if(table[pos.first][i] != 'B')
{
return i;
}
}
return i;
}
int getHeight(mypair pos)
{
int i;
for(i=pos.first; i<n; i++)
{
if(table[i][pos.second] != 'B')
{
return i;
}
}
return i;
}
int main()
{
//ios::sync_with_stdio(false);
//cin.tie(0);
cin >> n >> m;
for(int i=0; i<n; i++)
{
gets(table[i]);
}
initPos = getPositionOfB();
height = getHeight(initPos);
length = getLength(initPos);
coordinate.second = (initPos.second+length)/2;
coordinate.first = (initPos.first+height)/2;
cout << coordinate.first << " " << coordinate.second << "\n";
return 0;
}