Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main() {
- int t;
- cin>>t;
- while(t--)
- {
- string s,s1;
- vector<string>v;
- map<string,int>mp;
- char c;
- cin>>c;
- getline(cin,s);
- s=c+s;
- for(auto u:s)
- {
- if(isspace(u))
- {
- v.push_back(s1);
- s1.clear();
- }
- else
- {
- s1+=u;
- }
- }
- v.push_back(s1);
- for(int i=0;i<v.size();i++)
- {
- mp[v[i]]++;
- }
- string st;
- int ans=0;
- for(auto u:v)
- {
- if(mp[u]>ans)
- {
- st=u;
- ans=mp[u];
- }
- }
- cout<<st<<" "<<ans<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement