fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int n;
  6. vector<vector<char>> a;
  7.  
  8. string s;
  9.  
  10. void rec(int i) {
  11. if(i == n) {
  12. cout << s << endl;
  13. } else {
  14. for(size_t j = 0; j < a[i].size(); j++) {
  15. if(!j || (j && a[i][j]!=a[i][j-1])) {
  16. s[i] = a[i][j];
  17. rec(i+1);
  18. }
  19. }
  20. }
  21. }
  22.  
  23. int main() {
  24. a.push_back({'a','b','a'});
  25. a.push_back({'c','c'});
  26. a.push_back({'d','e','e','f'});
  27.  
  28. n = a.size();
  29.  
  30. for(int i = 0; i < n; i++) {
  31. sort(a[i].begin(), a[i].end());
  32. s += "#";
  33. }
  34.  
  35. rec(0);
  36. }
Success #stdin #stdout 0.01s 5304KB
stdin
Standard input is empty
stdout
acd
ace
acf
bcd
bce
bcf