fork(1) download
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4. #include <vector>
  5.  
  6. std::vector<std::string> translate(const std::vector<std::string>& v,
  7. const std::map<std::string, std::vector<std::string>>& m)
  8. {
  9. if (v.empty()) {
  10. return {};
  11. }
  12. std::vector<std::string> res = {""};
  13.  
  14. for (const auto& s : v) {
  15. std::vector<std::string> tmp;
  16.  
  17. for (const auto& seq : m.at(s)) {
  18. for (const auto& old: res) {
  19. tmp.push_back(old + seq);
  20. }
  21. }
  22. res = std::move(tmp);
  23. }
  24. return res;
  25. }
  26.  
  27.  
  28. int main()
  29. {
  30. const std::map<std::string, std::vector<std::string>> mapping = {{"K", {"AAA", "GAA"}}};
  31.  
  32. for (const auto& s : translate({"K", "K"}, mapping)) {
  33. std::cout << s << std::endl;
  34. }
  35.  
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0s 3236KB
stdin
Standard input is empty
stdout
AAAAAA
GAAAAA
AAAGAA
GAAGAA