#include <iostream>
#include <stdio.h> 
using namespace std;
bool book[4][5]={false} ;
int  map[4][5]={
1,2,3,4,5,
2,3,4,5,6,
3,4,5,6,7,
4,5,6,7,8
};
int next[4][2]={
0,-1,
0,1,
-1,0,
1,0
};
int ans=0;
void dfs(int x,int y){
if(x==3 && y==4){
ans++;
return;
}
for(int i=0;i<4;i++){
int nx=x+next[i][0];
int ny=y+next[i][1]; 
if(nx<0 || nx>=4 || ny <0 || ny>=5) continue;
if(book[nx][ny]==true) continue;
if(map[x][y]+1!=map[nx][ny]) continue;
book[nx][ny]=true;
dfs(nx,ny);
book[nx][ny]=false;
}
}


int main(int argc, char** argv) {
dfs(0,0);
printf("%d",ans);
return 0;

}

从我做起振新中华,dfs解

相关文章:

  • 2021-07-13
  • 2021-06-13
  • 2021-06-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-06-06
猜你喜欢
  • 2022-12-23
  • 2021-05-06
  • 2022-12-23
  • 2022-01-08
  • 2021-12-11
  • 2022-01-15
  • 2021-09-22
相关资源
相似解决方案