提交时间:2023-11-18 10:38:11
运行 ID: 111121
#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; int tmp = 0; for(int i = 0;i < len;i++){ if(b[a[i] - 'a'] > max){ max = b[a[i] - 'a']; } if(max == i){ printf("%d ",max+1-tmp); tmp = max+1; } } return 0; }