#34270: ru tj3ru,6z83


yp11151119@yphs.tp.edu.tw (802-32張鈞晏)

學校 : 臺北市私立延平高級中學
編號 : 197210
來源 : [203.72.178.1]
最後登入時間 :
2023-12-01 15:16:02
e837. P4. 字母排列 (Letters) -- 2019年08月TOI新手同好會 | From: [203.72.178.1] | 發表日期 : 2023-03-08 17:33

#include<bits/stdc++.h>//e837
using namespace std;
int main(){
    int cnt=1, len=1,pos;
    string s;
    cin>>s;
    for(int i=1;i<s.size();i++){
        s[i]-s[i-1]==1 ? cnt++ : cnt=1;
        if(cnt>=len){len=cnt; pos=i-cnt+1;}
    }
    cout<<len<<" "<<s.substr(pos,len)<<endl;
    return 0;
}

 

 
ZeroJudge Forum