fork(1) download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n;
  8. string str;
  9. map<string, int> vote;
  10. cin>>n;
  11. for(int i=0;i<n;i++)
  12. {
  13. getline(cin,str);
  14. vote.insert(pair<string, int>(str,vote[str]++));
  15. }
  16. for(map<string, int>::iterator it=vote.begin();it!=vote.end();it++)
  17. {
  18. cout<<it->first<<" => "<<it->second<<endl;
  19. }
  20. cout<<vote.size()<<endl;
  21. return 0;
  22. }
Success #stdin #stdout 0s 3464KB
stdin
2
mayank (now it shows output directly)
stdout
 => 1
mayank (now it shows output directly) => 1
2