Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- int main(){
- string a[2000];
- char b[2000];
- int num=0;
- int n;cin>>n;
- for(int i=0;i<n;i++){
- cin>>a[i];
- cin.getline(b,2000);
- }
- for(int i=0;i<n;i++){
- for(int j=i;j<n;j++){
- if(a[i]>a[j])swap(a[i],a[j]);
- }
- }
- int h=0;
- cout<<a[0]<<" ";
- for(int i=0;i<n;i++){
- if(a[h]!=a[i]){
- h=i;
- cout<<h-num<<endl;
- cout<<a[h]<<" ";
- num=h;
- }
- }
- cout<<n-h<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment