-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlb2.cpp
More file actions
executable file
·76 lines (63 loc) · 1.16 KB
/
lb2.cpp
File metadata and controls
executable file
·76 lines (63 loc) · 1.16 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
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long int
#define pb push_back
#define mk make_pair
#define flp(i, k, n) for(int i=k; i<n; i++)
#define F first
#define S second
#define SIZE 1005
int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,-1,1};
int n, m;
char grid[SIZE][SIZE];
bool vis[SIZE][SIZE];
int ans=0;
void dfs(int x, int y, int nodeCount)
{
if(x<0 || y<0 || x>=n || y>=m) return;
vis[x][y]=true;
nodeCount++;
ans=max(ans, nodeCount);
flp(k, 0, 4)
{
int xx=x+dx[k], yy=y+dy[k];
if(!vis[xx][yy]) dfs(xx, yy, nodeCount);
}
return ;
}
int32_t main(void)
{
int t;
cin>>t;
while(t--)
{
// int m, n;
memset(vis, 0, sizeof(vis));
scanf("%lld%lld", &m, &n);
flp(i, 0, n) cin>>grid[i];
int id=0;
vector<pair<int, int>> v;
flp(i, 0, n) flp(j, 0, m){
if(grid[i][j]=='.')
{
int dots=0;
flp(k, 0, 4)
{
int x=i+dx[k];
int y=j+dy[k];
if(x<0 || y<0 || x>=n ||y>=m ) continue;
if(grid[x][y]=='.')
dots++;
}
if(dots==1)
v.pb({i, j});
}
}
for(auto i:v)
cout<<i.F<<" "<<i.S<<"\n";
//cout<<"Maximum rope length is "<<(ans)<<".\n";
}
return 0;
}