fork download
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n ; cin>>n;
  7. unordered_map<string,int>hash;
  8. for(int i = 0 ; i<n;i++){
  9. string s;
  10. cin>>s;
  11. hash[s]++;
  12. }
  13. vector<string>ans;
  14. for(auto i : hash){
  15. if(i.second>1){
  16. ans.push_back(i.first);
  17. }
  18.  
  19. }
  20. sort(ans.begin(),ans.end());
  21. for(string i : ans) cout<<i<<" ";
  22. return 0;
  23. }
Success #stdin #stdout 0s 5252KB
stdin
7
batman latte cat matter cat matter cat
stdout
cat matter