提交时间:2023-11-28 13:19:14
运行 ID: 112724
#include<bits/stdc++.h> using namespace std; int b[1010]; int main ( ) { string a; cin >> a ; for ( int i = 0 ; i < a . size ( ) ; i ++ ) { b [a [ i ] - 'a'] = i ; } int max = 0 ; int tmp = 0 ; for(int i = 0 ; i < a . size ( ) ; i ++ ) { if ( b [a [i] - 'a'] > max ) { max = b [a [i] - 'a' ] ; } if ( max == i ) { cout << max + 1 - tmp << endl ; ; tmp = max + 1 ; } } return 0; }