SHARE
TWEET

Untitled

a guest Dec 8th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstdio>
  2. #include <map>
  3. #include <iostream>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int ans, n, check[15];
  9. char c[15];
  10. string a, b;
  11. map <string, int> ma;
  12.  
  13. void lucky(int cnt)
  14. {
  15.     if (cnt == n) {
  16.         if (ma[b] != 1) {
  17.             ans++;
  18.             printf("%s %d ", c, ma[b]);
  19.         }
  20.         ma[b] = 1;
  21.         printf("%d\n", ma[b]);
  22.         return;
  23.     }
  24.     for (int i = 0; i < n; i++) {
  25.         if (check[i] == 1) continue;
  26.         if (b[cnt - 1] == a[i]) continue;
  27.         b.push_back(a[i]);
  28.         c[cnt] = a[i];
  29.         check[i] = 1;
  30.         lucky(cnt + 1);
  31.         check[i] = 0;
  32.     }
  33. }
  34.  
  35. int main()
  36. {
  37.     cin >> a;
  38.     n = a.size();
  39.     lucky(0);
  40.     printf("%d", ans);
  41.     return 0;
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top