Advertisement
erfanul007

List

Dec 3rd, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<string>
  3.  
  4. using namespace std;
  5. int main()
  6. {
  7. vector<string>a;
  8. string x,y;
  9. int n,i,cnt;
  10. cin>>n;
  11. for(i=0;i<n;i++){
  12. cin>>x;
  13. scanf("%[^\n]",y);
  14. a.push_back(x);
  15. }
  16. sort(a.begin(),a.end());
  17. i=0;
  18. cnt=1;
  19. while(i<a.size()){
  20. if(a[i]==a[i+1]){
  21. cnt++;
  22. i++;
  23. continue;
  24. }
  25. else{
  26. cout<<a[i]<<" "<<cnt<<endl;
  27. cnt=1;
  28. i++;
  29. }
  30. }
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement