Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<string>
- using namespace std;
- int main()
- {
- vector<string>a;
- string x,y;
- int n,i,cnt;
- cin>>n;
- for(i=0;i<n;i++){
- cin>>x;
- scanf("%[^\n]",y);
- a.push_back(x);
- }
- sort(a.begin(),a.end());
- i=0;
- cnt=1;
- while(i<a.size()){
- if(a[i]==a[i+1]){
- cnt++;
- i++;
- continue;
- }
- else{
- cout<<a[i]<<" "<<cnt<<endl;
- cnt=1;
- i++;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement