C++ 代码
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
while(n--){
string s;
cin>>s;
int l=0,r=0,cnt=0;
char c;
int len=s.size();
while(l<len&&r<len){
r=l;
while(s[r]==s[r+1]) r++;
if(r-l+1>cnt) cnt=r-l+1,c=s[r];
l=r+1;
}
cout<<c<<" "<<cnt<<endl;
}
return 0;
}