-
Notifications
You must be signed in to change notification settings - Fork 0
/
129.cpp
42 lines (39 loc) · 900 Bytes
/
129.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = (1 << 20) + 5;
char s[maxn];
void duval(char s[], int n) {
for (int i = 1, j, k; i <= n; ) {
j = i; k = i + 1;
while (k <= n && s[j] <= s[k]) {
if (s[j] < s[k]) {
j = i;
} else {
j++;
}
k++;
}
while (i <= j) {
// s[i ... i + k - j - 1]
printf("%d ", i + k - j - 1);
i += k - j;
}
}
}
int main() {
scanf("%s", s + 1);
duval(s, strlen(s + 1));
return 0;
}