Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define pb push_back
- using namespace std;
- map<char , bool> mp;
- vector<char> p;
- string s;
- void print(){
- for( auto z : p ) putchar( z );
- puts("");
- }
- void DFS( int l ){
- if( l == s.size() - 1 ){
- print();
- return;
- }
- for( auto z : s ){
- if( mp[ z ] ) continue;
- p.pb( z );
- mp[ z ] = 1;
- DFS( l + 1 );
- mp[ z ] = 0;
- p.pop_back();
- }
- return;
- }
- int main(){
- cin >> s;
- for( auto z : s ){
- p.pb( z );
- mp[ z ] = 1;
- DFS( 0 );
- mp[ z ] = 0;
- p.pop_back();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement