-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1622.cpp
62 lines (48 loc) · 1.12 KB
/
1622.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// #include <iostream>
// #include <set>
// using namespace std;
// set<string> ans;
// bool chosen[10];
// string s, permutation;
// void Try() {
// if (permutation.size() == s.size()) {
// ans.insert(permutation);
// return;
// }
// for (int i = 0; i < s.size(); i++) {
// if (chosen[i])
// continue;
// chosen[i] = true;
// permutation.push_back(s[i]);
// Try();
// chosen[i] = false;
// permutation.pop_back();
// }
// }
// int main() {
// cin.tie(0) -> ios_base::sync_with_stdio(0);
// cin >> s;
// Try();
// cout << ans.size() << '\n';
// for (string x : ans)
// cout << x << '\n';
// return 0;
// }
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
string s;
set<string> ans;
int main() {
cin.tie(0) -> ios_base::sync_with_stdio(0);
cin >> s;
sort(s.begin(), s.end());
do {
ans.insert(s);
} while (next_permutation(s.begin(), s.end()));
cout << ans.size() << '\n';
for (string x : ans)
cout << x << '\n';
return 0;
}