lanqiao 19712 数字接龙

This commit is contained in:
2025-04-08 17:24:51 +08:00
parent cb3ab139da
commit 1b36366014

View File

@@ -10,6 +10,7 @@ int dx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dy[] = { 0, 1, 1, 1, 0, -1, -1, -1};
string res; // 结果字符串
// x, y为搜索的位置坐标, pre 前一个访问位置的数字, s 当前路径的访问序列, dep 搜索的深度
void dfs(int x, int y, int pre, string s, int dep){
if(x == n && y == n && dep == n*n){
if(res.empty()) res = s; // 字典需最小的