题目:
 
分析:考虑到了aab这种重复,但是自己只是简单的做了这种last:(而且刚开始忘记了先排序),哦,是完全可以的。
 
 
相当于把重复的都剪了。
 
#include<bits/stdc++.h>
using namespace std
;
vector
<string
> vs
;  
void f(string s
,vector
<int> v
,string ans
)
{
 char last
='0';
 if(ans
.length()==s
.length()) {
  vs
.push_back(ans
);
  return ;
 }
 for(int i
=0;i
<v
.size();i
++)
 {
  if(v
[i
]==1) continue;
  if(s
[i
]==last
) continue;
  v
[i
]=1;
  f(s
,v
,ans
+s
[i
]);
  last
=s
[i
]; 
  v
[i
]=0;
 }
}
int main()
{
 string s
;
 sort(s
.begin(),s
.end());
 vector
<int> v(s
.length(),0);
 string ans
="";
 f(s
,v
,ans
);
 return vs
;
}
                
                
                
        
    
                    转载请注明原文地址: https://lol.8miu.com/read-435.html