提交时间:2023-11-29 16:58:06
运行 ID: 112923
# include <bits/stdc++.h> using namespace std ; string a ; int b [1010] ; int main ( ) { cin >> a ; int len = a.size ( ) ; for ( int i = 0 ; i < len ; i ++ ) { b [a [i] - 'a'] = i ; } int max = 0 , tmp = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( b [a [i] - 'a'] > max ) { max = b [a [i] - 'a'] ; } if ( max == i ) { cout << max + 1 - tmp ; tmp = max + 1 ; } } return 0 ; }