QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#93770 | #6181. 重复函数问题 | Renshey | 100 ✓ | 183ms | 55712kb | C++23 | 1.1kb | 2023-04-02 10:33:25 | 2023-04-02 10:33:29 |
Judging History
answer
#include <bits/stdc++.h>
const int maxn = 1000000 + 10;
int n, times, nxt[maxn], fa[maxn], L[maxn], R[maxn], ans[maxn];
std::vector<int> e[maxn]; char S[maxn];
inline void dfs (int u)
{
L[u] = ++times;
for (int v: e[u]) dfs(v);
R[u] = times;
}
inline bool Subtree (int u, int v) {return L[u] <= L[v] and R[v] <= R[u];}
inline int find (int x) {return fa[x] == x ? x : fa[x] = find(fa[x]);}
signed main ()
{
scanf("%s", S + 1); n = strlen(S + 1);
for (int i = 2, j = 0; i <= n; i++)
{
while (j and S[j + 1] != S[i]) j = nxt[j];
if (S[j + 1] == S[i]) j++;
nxt[i] = j;
}
for (int i = 1; i <= n; i++) e[nxt[i]].push_back(i), fa[i] = i;
dfs(0);
for (int i = 1; i <= n / 2; i++) if (Subtree(i, n))
{
int w = 2;
for (int j = 2 * i; j <= n - i; j = find(j) + 1) Subtree(i, j) ? (w++, j += i - 1) : (fa[j - 1] = j);
ans[w] = i;
}
for (int i = n; i >= 2; i--) ans[i] = std::max(ans[i], ans[i + 1]);
for (int i = 2; i <= n; i++) printf("%d%c", ans[i], " \n"[i == n]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 5
Accepted
time: 4ms
memory: 36984kb
input:
dbabeaaaaabccdbadbabeaaaaabccdbadbabeabaaabccdbadbabeaaaaabccdbadbabeaaaaabccdbadbabeaaaaabcdabadbabeaaaaabccdbadbabeaaaaabacdbadbabeaaaaabccdaadbabeaaaaabccdbadbadeaaaaabacdbadbabeaaababccabadbabeaaaaabccdbadbabbaabaabkcdbadbabeaaaaabccdbadbabebaaaabccdbadbaaeaaaaaacadbadbabeaaaaabccdbadbabeaaaaabc
output:
28 28 12 12 12 12 12 12 12 12 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 299 numbers
Test #2:
score: 5
Accepted
time: 4ms
memory: 36392kb
input:
debadebadebadebadebadebadebadebadebadebadebadebadebadebadebbdebfdebadebadegbaebadebadebadebadebadecadebabebadebgdebhdhbadebadebodcbadeaadeaadebadebadebadebadebadebaiebadebadbbadebadebdneaaaebadeeadebadeeadebadeaadabadebadebadebadlbaafnadabadeaadebadebadebadebadebadebadebadebadebadebadebadebadebadeba
output:
56 28 28 24 16 16 16 12 12 12 12 8 8 8 8 8 8 8 8 8 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 299 numbers
Test #3:
score: 5
Accepted
time: 3ms
memory: 36760kb
input:
ldcmbfbaebacibaldcmbfbaebacibaldcmbfbaebacibaldcmbfbaebaciaalgcmbfbaebacibaldcmbfbaebacibaldcmbfbaebacibaldcmbfbdebacabaldcmbfbaebacibaldcmbfbaebacibaldcmbfhaebacibalccmbfbabiacibaldcmbfdaeabcgbaldcmbfbaebacbbaldcmbfbaabacibaldcmbfbaebacibaddcmbfeaebacibalbcmbfbeebacibaldcmafbaeaaciaabdcmbfbaebaciia...
output:
45 45 45 45 45 45 45 45 45 30 30 30 30 30 30 30 30 30 30 30 30 30 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 2999 numbers
Test #4:
score: 5
Accepted
time: 4ms
memory: 36908kb
input:
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccacccccccccccccccccccccccaccccccccccccccacccccccccccccccccccfcccccfcccccccccccccccccccccaccccccccccbccccccccccaccccccccccccbccccccccccccccbccccccccc...
output:
153 94 88 76 66 66 59 56 55 51 50 49 47 44 43 43 41 41 39 38 35 35 35 34 34 33 33 32 31 31 31 31 30 30 29 29 29 29 28 28 28 27 27 27 27 26 26 26 26 25 25 25 25 24 24 24 23 23 23 23 23 23 22 22 22 22 22 21 21 21 21 20 20 20 19 19 19 19 19 18 18 18 18 18 18 17 17 17 17 17 17 17 17 16 16 16 16 16 16 16...
result:
ok 2999 numbers
Test #5:
score: 5
Accepted
time: 5ms
memory: 36412kb
input:
aaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaedfaaebfaaebfaaedcaaedfoaedeaaedfaaebfaaedfaaedfaaedfaaedfaaedfaaedfacecfaaedfaaedfaaebfgaedfaaadfaaedfaaedfaaedfaaeefhaedfaaedfaaedfaaedfanedfaaedf...
output:
150 80 75 75 65 55 50 50 50 50 45 45 45 40 40 40 40 35 35 35 35 35 30 30 30 30 30 30 30 30 30 30 30 30 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15...
result:
ok 2999 numbers
Test #6:
score: 5
Accepted
time: 3ms
memory: 36352kb
input:
aaaaehcgcaaaaehcgcaaaaehcgcaaaaehcgcaaaaehcgcaaaaehcgcaaaaehcgcaaaaehcgcaaaaehcgcaaaaehcgcaaaaehcgcaaaaeabgcaaaaehggcaaaaeacgcaaaaehcgcaaaaehcgcaaaaeaagcaaaaehcgcaaaaehcgccaaaebcgcaaaaehcgcaaaaehcgcaaakehcgcaaaaehcgchaaaehcgcacaaehcghaaagehcgcaaaaehjgcaaaaehcgcaaaaebcbcaacaehcgcaaaaehcgcaaaaehcgcaaa...
output:
93 48 48 48 48 39 39 39 39 39 39 39 39 39 30 30 30 30 30 30 30 30 30 30 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 3 3...
result:
ok 2999 numbers
Test #7:
score: 5
Accepted
time: 27ms
memory: 40404kb
input:
fdeaacqcacbgmabfbrfaaaalbabeaaejbfabbcaaaaaiaegcaabbfmfbaoanaebbgaddmaaabaanahabadlaadecaacagaebafdeaacqcacbgmabfbrfaaaalbabeaaejbfabbcaaaaaiaegcaabbfmfbaoanaebbgaddmaaabaanahabadlaadecaacagaebafdeaacqcacbgmabfbrfaaaalbabeaaejbfabbcaaaaaiaegcaabbfmfbaoanaebbgaddmaaabaanahabadlaadecaacagaebafdeaacqca...
output:
20065 10074 9977 6679 6679 5030 4933 3963 3963 3284 3284 2799 2799 2508 2411 2217 2217 1926 1926 1732 1732 1635 1635 1538 1441 1344 1344 1247 1247 1247 1150 1150 1150 1053 1053 1053 956 956 956 956 956 956 859 859 859 859 859 859 859 859 859 762 762 762 762 762 762 762 762 762 762 665 665 665 665 66...
result:
ok 199999 numbers
Test #8:
score: 5
Accepted
time: 19ms
memory: 37068kb
input:
laaaakeclaadeaibaahencaabygcxadibfbalafhbelicdjaadcdcaabbccablccdbacabdhdbagaaabdbgfaiaagaaqaelaaaakeclaadeaibaahencaabygcxadibfbalafhbelicdjaadcdcaabbcgablccdbacabdhdbagacabdbgfbiaaiaaqaelaaaakeclaadeaieaahencaabygcxadibfbalaahbelicdaaadcdcaabbccablccddacabdhdbagaaabdbgfaiaagaaqaelaaaakeclaadeaebaa...
output:
62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 199999 numbers
Test #9:
score: 5
Accepted
time: 27ms
memory: 37300kb
input:
dibhabddabdageaaaadgbbfbefckaacdfcbcbbgdagdcacbdicabaaaabbablabheaahdibhabddabdageaaaadgbbfbefckaacdfcbcbbgdagdcacbdicabaaaabbablabheaahdibhabddabdageaaaadgmbfbefckaacdfcbcabgddgdcaabdicbbbaaabbaalabheaahdibhabddabdageaaaadgbbfbefckaacdfcbcbbadagdcacbdicabaaaabbablabheaahdibhkbddabdageaaaadcbafbefck...
output:
148 80 80 80 80 80 80 80 80 80 80 80 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12...
result:
ok 199999 numbers
Test #10:
score: 5
Accepted
time: 22ms
memory: 41672kb
input:
cbfatdaacaaacjacbiaaaaajambaabdecadcjceafjacbfatdaacaaacjacbiaaaaajambaabdecadcjceafjacbfatdaacaaacjacbiaaaaajambaabdecadcjceafjacbfatdaacaaacjacbiaaaaabambaabiecbacjceafjacbfatdabcaaacjbcbiaaaaajambaabdecaacjcemfjacbfatdaacaaacjacbiaaaaajambaacdecagcjceafjacbfatdaacabacjacbiaaaaajambaabdecadcjceafj...
output:
136 93 93 93 93 93 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50...
result:
ok 199999 numbers
Test #11:
score: 5
Accepted
time: 24ms
memory: 39744kb
input:
aanaadabafbgaanaadabafbgaanaadabafbgaanaadabafbgaanaadabafbgaanaadabafbgaanaadabafbgaanaadabafbgaanaadabafbgaanaadabafbgaanaadabafbgaanaadabafbgaanaadabafbgajnaadabafbgaanaadabafbgaanaddabafbgaanaadababagadnaadabafbgaanaadebafbaaanaadabafbgaanaadabbfbgaanaadababbgaanabdabafbgaanaadabafbgaanaadabafbg...
output:
152 128 116 116 104 104 104 104 104 104 104 104 104 92 92 92 92 92 92 92 92 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68...
result:
ok 199999 numbers
Test #12:
score: 5
Accepted
time: 26ms
memory: 39512kb
input:
adlaaaebacjabbafebafbkaaechcaakdacclhbaebbeafkbbaabaabecahbegabbfaibbdbfabaaadodaakadlaaaebacjabbafebafbkaaechcaakdacclhbaebbeafkbbaabaabecahbegabbfaibbdbfjbaabdodaakaalqaaebacjabeafebafbaaaechcaakracglhbaebbeafkbbcabaabecahbegabbfaibbdbfabaaadodaakadlaaaebacbabbafebafbkaaechcakkdacclhbaebbeafkbbaab...
output:
136 136 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 199999 numbers
Test #13:
score: 5
Accepted
time: 21ms
memory: 37148kb
input:
antabfebhlnahgaabhbdadpdabbabedbaabeadaaaccadakbbadikblacaaaadbabccabdjbadbhbaaaaantabfebhlnahgaabhbdadpdabbabedbaabeadaaaccadakbbadikblacaaaadbabccabdjbadbhbiaaaantagfebhlnahgaabhbdadpdabbabedbaabecdaaadcadakbbadikblacaaaddbabccabdjatdbhbaaaaantabfeghlnahgaabhbdadpdabbabedbaabeadaaaccadakbbadikblac...
output:
92 92 92 92 92 92 92 92 92 92 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ...
result:
ok 199999 numbers
Test #14:
score: 5
Accepted
time: 24ms
memory: 41780kb
input:
bccaceeibbeakdibahabaeabbpgiabaabbadcagkafgbkdamaacaaacfcgedagacbckacaaakfkdabgfbhbfeakdhaaebbadababigacadadakabokaanbccaceeibbeakdibahabaeabbpgiabaabbadcagkafgbkdamaacaaacfcgedagacbckacaaakfkdabgfbhbfeakdhaaebbadababigacadadakabokaanbccaceeibbeakdibahabaeabbpgiabaabbadcagkafgbkdamaacaaacfcgedagacbc...
output:
4961 2387 2387 1568 1568 1100 1100 866 866 749 749 632 632 515 515 398 398 398 398 281 281 281 281 281 281 281 281 164 164 164 164 164 164 164 164 164 164 164 164 164 164 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 ...
result:
ok 199999 numbers
Test #15:
score: 5
Accepted
time: 7ms
memory: 37328kb
input:
fbacbcahabigcaahghbhbaadgafbacbcahabigcaahghbhbaadgafbacbcahabigcaahghbhbaadgafbacbcahabigcaahghbhbaadgafbacbcahabigcaahghbhbaadgafbacbcahabigcaahghbhbaadgafbacbcahabigcaahghbhaaabgafbacbcahabigdfahghbhbaadgafbdcbcahabigcaahghbhdaadgafbacbcahabigcaahghahbaadgabbacbcahabigcaahghbhbaadgafbacbcahabigca...
output:
164 138 112 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 ...
result:
ok 199999 numbers
Test #16:
score: 5
Accepted
time: 24ms
memory: 37336kb
input:
dadbmcbecgceamccbbcjaaacbcdqaddadbmcbecgceamccbbcjaaacbcdqaddadbmcbecgceamccbbcjaaacbcdqaddadbmcbecgceamccbbcjaaacbcdqaddadbmcbecgceamccbbcjaaacbcdqaddadbmccecgcebmccbbcjaajcbcdqaddadbfcbecgceamccbbcjiaacbcdqadhadbmcbecgceamccbbcjaaacbcdqaddadbmcbecgceamccbbcjaaacbadqaddadbmcbecgceamccbbcjagacbcdqad...
output:
140 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50...
result:
ok 199999 numbers
Test #17:
score: 5
Accepted
time: 140ms
memory: 54868kb
input:
ldawaaefcgagabeeaabecjwbdaaadfiaeackcbcacacabadafiedhbgfcaaiaabfaccicebcffcjcmaaaaabaaagbaacbehdaeakibbehaiafbebbfbifabcaecafaoahhceecicheagdaicdbualdawaaefcgagabeeaabecjwbdaaadfiaeackcbcacacabadafiedhbgfcaaiaabfaccicebcffcjcmaaaaabaaagbaacbehdaeakibbehaiafbebbfbifabcaecafaoahhceecicheagdaicdbualdaw...
output:
114960 106672 71004 57388 53244 42588 38296 35484 30452 28676 26604 23644 22904 21276 19352 19056 17724 16392 16244 15208 14320 14172 13284 12692 12396 11804 11360 11064 10620 10324 10028 9584 9436 9140 8844 8696 8400 8104 8104 7808 7512 7512 7216 7068 7068 6772 6624 6624 6328 6328 6180 6032 5884 58...
result:
ok 999999 numbers
Test #18:
score: 5
Accepted
time: 183ms
memory: 55712kb
input:
acahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaejbbehfaacahhafaaej...
output:
115337 59492 57656 39653 38429 29742 28824 23792 23537 23061 21582 19814 19763 19372 19304 19202 18505 17791 17077 16992 16465 16278 15921 15275 14867 14510 14408 14034 13915 13830 13694 13643 13371 13201 13167 13048 12793 12640 11892 11892 11756 11518 11042 10804 10787 10787 10566 10566 10498 10464...
result:
ok 999999 numbers
Test #19:
score: 5
Accepted
time: 97ms
memory: 52668kb
input:
eagbgaceaaacbfckaasaalabhhweigddbbckfaababaadddbhcaaaacctgcfdacdbabldbajageacbnafabefbaacbkbcbaobebbaabaaakakeicdcagadbkcabcaaieobdaaanaeedbraajibeagbbaaacbabcjahdakcdaabeeaicldadaeadbabcfidbajaabjfafdabcdeaaddagaaacjaadamdaaababqbebdbblsweaadaeccacacbemcbpadaaaalasbaccccibebbecbaalafaacbfdmahabahjj...
output:
270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 ...
result:
ok 999999 numbers
Test #20:
score: 5
Accepted
time: 97ms
memory: 52816kb
input:
ifdabdbacceabebbceafbbacealaachbajbaieaiaccgaacbbaaadafegkaccdabbdkaabhecbhadfaabbcebaaaeaegdecaifdabdbacceabebbceafbbacealaachbajbaieaiaccgaacbbaaadafegkaccdabbdkaabhecbhadfaabbcebaaaeaegdecaifdabdbacceabebbceafbbacealaachbajbaieaiaccgaacbbaaadafegkaccdabbdkaabhecbhadfaabbcebaaaeaegdecaifdabdbaccea...
output:
20224 10336 10048 6880 6688 5152 4960 4096 4000 3424 3328 2848 2848 2560 2464 2272 2176 1984 1984 1792 1792 1696 1600 1600 1504 1504 1408 1408 1408 1312 1312 1216 1216 1216 1120 1120 1120 1120 1120 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 928 928 928 928 928 928 928 928 928 928 928 928 832 ...
result:
ok 999999 numbers