Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <map>
- #include <iostream>
- #include <string>
- using namespace std;
- int ans, n, check[15];
- char c[15];
- string a, b;
- map <string, int> ma;
- void lucky(int cnt)
- {
- if (cnt == n) {
- if (ma[b] != 1) {
- ans++;
- printf("%s %d ", c, ma[b]);
- }
- ma[b] = 1;
- printf("%d\n", ma[b]);
- return;
- }
- for (int i = 0; i < n; i++) {
- if (check[i] == 1) continue;
- if (b[cnt - 1] == a[i]) continue;
- b.push_back(a[i]);
- c[cnt] = a[i];
- check[i] = 1;
- lucky(cnt + 1);
- check[i] = 0;
- }
- }
- int main()
- {
- cin >> a;
- n = a.size();
- lucky(0);
- printf("%d", ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement