Advertisement
erfanul007

UVa 10420

Dec 3rd, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 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;
  9. char y[100];
  10. int n,i,cnt,j;
  11. cin>>n;
  12. for(i=0;i<n;i++){
  13. cin>>x;
  14. scanf("%[^\n]",y);
  15. a.push_back(x);
  16. }
  17. sort(a.begin(),a.end());
  18. a.push_back("-1");
  19. i=0;
  20. cnt=1;
  21. while(i<a.size()-1){
  22. if(a[i]==a[i+1]){
  23. cnt++;
  24. i++;
  25. continue;
  26. }
  27. cout<<a[i]<<" "<<cnt<<endl;
  28. cnt=1;
  29. i++;
  30. }
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement