-
Notifications
You must be signed in to change notification settings - Fork 0
/
1985D.cpp
53 lines (42 loc) · 886 Bytes
/
1985D.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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t, n, m, h, k;
vector<tuple<int, int>> answers;
string line;
cin >> t;
while (t--)
{
cin >> n >> m;
cin.ignore();
vector<string> grid(n);
vector<tuple<int, int>> positions;
for (int i = 0; i < n; ++i)
{
getline(cin, grid[i]);
}
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
if (grid[i][j] == '#')
{
positions.push_back(make_tuple(i, j));
}
}
}
if (!positions.empty())
{
auto first = positions.front();
auto last = positions.back();
h = ((get<0>(first) + get<0>(last)) / 2) + 1;
k = ((get<1>(first) + get<1>(last)) / 2) + 1;
answers.push_back(make_tuple(h, k));
}
}
for (const auto& a : answers)
{
cout << get<0>(a) << ' ' << get<1>(a) << endl;
}
}