我的代码在其它网站都能过,但在这全WA,大神看看
我的代码在其它网站都能过,但在这全WA,大神看看
#include<bits/stdc++.h>
using namespace std;
const int N=9+5;
int n;
int a[N];
bool ab[N];
void dfs(int u)
{
if(u>n)
{
for(int i=1;i<=n;i++)
cout<<setw(5)<<a[i]<<" \n"[i==n];
cout<<endl
return;
}
for(int i=1;i<=n;i++)
{
if(ab[i]) continue;
a[u]=i;
ab[i]=true;
dfs(u+1);
a[u]=0;
ab[i]=false;
}
}
int main()
{
cin>>n;
dfs(1);
}