#39634: c++答案


yp11251144@yphs.tp.edu.tw (704-38曾湛)

學校 : 臺北市私立延平高級中學
編號 : 237373
來源 : [203.72.178.1]
最後登入時間 :
2024-03-14 17:42:31
e837. P4. 字母排列 (Letters) -- 2019年08月TOI新手同好會 | From: [203.72.178.1] | 發表日期 : 2024-03-14 17:44

#include <bits/stdc++.h>
using namespace std;
 
int main()
{
int count=1, length=1,pos;
string s;
cin>>s;
for(int i=1; i<s.length(); i++){
if(s[i]-s[i-1]==1) count++;
else count=1;
if(count>=length) {length=count; pos=i-count+1;} 
    cout<<length<<" "<<s.substr(pos, length)<<"\n";
}
 
 
 
 
 
 
ZeroJudge Forum