#include<bits/stdc++.h>
using namespace std;
char mp[110][110];
struct node{
int x,y;
int step;
};
int dir[4,2]={-1,0,1,0,0,-1,0,1}
bool vis[110][110],flag;
void bfs(int x,int y){
queue<node> q;
q.push({x,y,0});
vis[x][y]=true;
while(!q.empty()){
node top=q.front();
q.pop();
int now_x=top.x;
int now_y=top.y;
int now_step=top.step;
if(now_xn&&now_ym){
cout<<now_step;
flag=true;
break;
}
for (int i=0;i<4;i++){
int new_x=temp_x+dir[i][0];
int new_y=temp_y+dir[i][1];
//vis[temp_x][temp_y]=true;
if(new_x>=1&&new_x<=n
&&new_y>=1&&new_y<=m
&&mp[new_x][new_y]!='#'
&&vis[new_x][new_y]==false){
vis[new_x][new_y]=true;
q.push({new_x,new_y,temp_step+1});
}
int main(){
int>>n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
cin>>mp[i][j];
}
}
bfs(1,1);
if(flagfalse){
cout<<-1;
}
return 0;
}
//广搜
////////////////////////////////////////
////////////////////////////////////////
//深搜
#include<bits/stdc++.h>
using namespace std;
char mp[50][50];
int n,m;
int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
bool vis[50][50];
bool flag;
void dfs(int x,int y){
if(xn&&ym){
flag=true;
return ;
vis[x][y]=true;
for (int i=0;i<4;i++){
int new_x=x+dir[i][0];
int new_y=y+dir[i][1];
if(new_x>=1&&new_x<=n
&&new_y>=1&&new_y<=m
&&mp[new_x][new_y]'.'
&&vis[new_x][new_y]!=true){
dfs(new_x,new_y);
}
}
}
int main(){
freopen("migong.in","r",stdin);
freopen("migong.out","w",stdout);
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>mp[i][j];
}
}
dfs(1,1);
if(flag==true){
cout<<"YES";
}else{
cout<<"NO";
}
///////////////////////////////////////////////
//魔法草药
#include<bits/stdc++.h>
using namespace std;
struct node{
double weight;
double value;
double rate;
};
node a[110];
bool cmp(node x,node y){
return x.rate>y.rate;
};
int main(){
int s,w;
cin>>s>>w;
}
///////////////////////////////////////////////
//查找
#include<bits/stdc++.h>;
using namespace std;
bool flag=false;
int main(){
int l=1,n,r,x;
cin>>n;
int a[110];
for (int i=1;i<=n;i++){
cin >>a[i];
}
cin>>x;
sort(a+1,a+n+1);
int left=1,right=n;
while(left<=right){
int mid=(left+right)/2;
if(a[mid]==x){
cout<<mid;
flag=true;
break;
}else if(a[mid]<x){
left=mid+1;
}else{
right=mid-1;
}
}
if (flag == false){
cout<<"-1";
}
return 0;
}