|
- #include <algorithm>
- #include <iostream>
- #include <cstring>
- #include <cstdio>
- #include <cstdlib>
- using namespace std;
- int n,book[600],all=0;
- char a[600],cun[600];
- void dfs(int cen)
- {
- if(cen==n)
- {
- puts(cun),all++;
- return;
- }
- int boln[26]={0};
- for(int i=0;i<n;i++)
- if(!book[i]&&!boln[a[i]-'a'])
- {
- book[i]=1,boln[a[i]-'a']=1,cun[cen]=a[i];
- dfs(cen+1);
- book[i]=0;
- }
- }
- int main()
- {
- scanf("%d%s",&n,a);
- sort(a,a+n);
- dfs(0);
- printf("%d",all);
- return 0;
- }
复制代码 |
|