江西省住房和城乡建设厅,贵阳seo计费管理,建设网站需要什么资质吗,网站死链怎么处理思路#xff1a;for 代表的是每一位的纵向#xff0c;数字变化#xff0c;dfs 代表的是横向的#xff0c;位置变化。vis 来做到每个枚举的数不重复#xff0c;并且要在搜索前记录#xff0c;搜索后还原。模拟该样例 dfs3 的时候是输出#xff0c;dfs0#xff0c;1…思路for 代表的是每一位的纵向数字变化dfs 代表的是横向的位置变化。vis 来做到每个枚举的数不重复并且要在搜索前记录搜索后还原。模拟该样例 dfs3 的时候是输出dfs012 是枚举某位置的数字。复杂度是 n!*n。
#includeiostream
using namespace std;int n;
int vis[10],path[10];
void dfs(int dep){if(depn){for(int i0;in;i)coutpath[i] ;coutendl;return ;}for(int i 1;in;i){if(!vis[i]){vis[i]true;path[dep]i;dfs(dep1);vis[i]false;}}
}
int main( ){cinn;dfs(0);return 0;
}