-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathManhattan.cpp
More file actions
95 lines (85 loc) · 1.97 KB
/
Manhattan.cpp
File metadata and controls
95 lines (85 loc) · 1.97 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define flash \
ios_base ::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define cc continue
#define bb break
#define ssort(a) sort(a.begin(), a.end());
#define pll pair<ll, ll>
#define pdl pair<double, ll>
#define mp make_pair
const ll GEN = 1e5 + 1, MOD = 1e9 + 7, OO = 1e18 + 10;
// N S W E
ll dx[] = {-1, 1, 0, 0}; // i-->Row
ll dy[] = {0, 0, -1, 1}; // j-->Column
string path = "UDLR";
string alpha = "abcdefghijklmnopqrstuvwxyz";
string numeric = "0123456789";
bool compare(pair<ll, ll> v1, pair<ll, ll> v2)
{
return v1.second > v2.second;
}
// Z-algorithm
vector<int> z_function_trivial(string s)
{
int n = s.size();
vector<int> z(n);
for (int i = 1; i < n; i++)
{
while (i + z[i] < n && s[z[i]] == s[i + z[i]])
{
z[i]++;
}
}
return z;
}
void lets_do_it(){
ll a,b;
cin>>a>>b;
vector<vector<char>> v(a,vector<char>(b));
ll count = 0,x,y;
for(int i=0;i<a;i++){
bool flag = true;
for(int j=0;j<b;j++){
cin>>v[i][j];
if(v[i][j] == '#' && flag){
count++;
x = i;
y = j;
flag = false;
}
}
}
if(count == 1){
cout<<x+1<<" "<<y+1<<endl;
}else{
ll to = x - count/2;
ll idx = 0;
count = 0;
for(int i=0;i<b;i++){
if(v[to][i] == '#'){
idx = i;
count++;
}
}
cout<<to+1<<" "<<idx - count/2 + 1<<endl;
}
}
int main(){
flash;
ll num = 1;
cin>>num;
while(num--){
lets_do_it();
}
// cerr << "Time : " << 1000 * ((double)clock()) / CLOCKS_PER_SEC << "ms" << endl;
}