提交时间:2024-03-02 13:06:58
运行 ID: 134068
#include<bits/stdc++.h> using namespace std; const int N=1e4+10; int t[N]; string s; int x; int main(){ cin>>s; int ma=0; for(int i=0;i<s.size();i++){ for(int j=i;j<s.size();j++){ if(s[j]==s[i]){ ma=max(ma,j); } } if(ma==i){ t[++x]=ma; } } for(int i=1;i<=x;i++){ if(i==1){ printf("%d ",t[i]+1); } else{ printf("%d ",t[i]-t[i-1]); } } printf("\n"); return 0; }