摘要
题目链接 |
难度等级 |
完成状态 |
完成分数 |
最后编辑时间 |
失误原因(初次提交分数)
|
全排列
|
★☆☆☆☆
|
答案正确
|
100
|
2014-10-13 08:45:22
|
ios超时(80)
|
题意
输出全排列。
题解
dfs裸搜就好了。
就是ios处理大批量数据的时候会超时,还是建议用C形式的输入输出(scanf,printf)。
代码
1294.cpp代码已折叠
展开折叠内容
|
- #include<cstdio>
- int l[11],n;
- bool u[11];
- void dfs(const int& i)
- {
- if(i>n)
- {
- for(int j=1;j<=n;++j)
- printf("%d ",l[j]);
- printf("\n");
- return;
- }
- for(int j=1;j<=n;++j)
- if(!u[j])
- {
- l[i]=j;
- u[j]=1;
- dfs(i+1);
- u[j]=0;
- }
- }
- int main()
- {
- scanf("%d",&n);
- dfs(1);
- return 0;
- }
|