1 solutions

  • 0
    @ 2025-12-25 16:00:31

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    string s;
    int n,ans,tmp=1,t,a[95];
    char c;
    int main()
    {
    	cin>>n>>s;
    	s=s+'a';
    	for(int i=0;i<s.size();i++)
    		if(s[i]==s[i+1]) tmp++;
    		else{
    			if(tmp>ans) ans=tmp,t=i;
    			tmp=1;			
    		}
    	cout<<ans<<endl<<s[t];
    	return 0;
    }
    
    • 1

    Information

    ID
    1086
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    5
    Accepted
    2
    Uploaded By