fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <map>
  5.  
  6. typedef std::map<std::string, std::vector<std::string>> MType;
  7.  
  8. int main() {
  9. MType M{{ "A",{"2019 / 07 / 05","2019 / 07 / 10","2019 / 07 / 15","2019 / 07 / 20"}},
  10. { "B",{"2019 / 07 / 08","2019 / 07 / 10","2019 / 07 / 20"}},
  11. { "C",{"2019 / 07 / 15","2019 / 07 / 20","2019 / 07 / 25"}},
  12. };
  13.  
  14. MType D;
  15.  
  16. for (auto& oo : M) {
  17. for (auto& o : oo.second) {
  18. D[o].push_back( oo.first);
  19. }
  20. }
  21.  
  22. for (auto& oo : D) {
  23. if (oo.second.size() < 2)continue;
  24. std::cout << oo.first << ':';
  25. for (auto& o : oo.second) {
  26. std::cout << o << ' ';
  27. }
  28. std::cout << std::endl;
  29. }
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
2019 / 07 / 10:A B 
2019 / 07 / 15:A C 
2019 / 07 / 20:A B C